Click here to Skip to main content
15,883,887 members
Articles / Web Development / ASP.NET

ASP.NET MVC Chart Control

Rate me:
Please Sign up or sign in to vote.
4.86/5 (59 votes)
15 Nov 2010CPOL5 min read 311.1K   17.4K   148  
Shows how chart controls are used in ASP.NET MVC
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ChartApplication;
using ChartApplication.Models;
using ChartApplication.Services;

namespace ChartApplication.Controllers
{
    public class ResultController : Controller
    {
        private readonly IResultService _resultService;
        public ResultController()
        {
            _resultService = new TheService().ResultService;
        }
        //
        // GET: /People/

        public ActionResult Index()
        {
            return View();
        }

        //
        // GET: /People/Add/5

        [HttpGet]
        public ActionResult Save(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                ResultModel model = _resultService.GetResult(id);
            }
            IList<ResultModel> results = _resultService.GetResults();
            ViewData["results"] = results;
            return View("Save");
        }
        [HttpPost]
        public ActionResult Save(ResultModel result)
        {
           // if (String.IsNullOrEmpty(result.ID)) throw new ArgumentException("Value cannot be null or empty.", "ID");
           // if (String.IsNullOrEmpty(result.GPA)) throw new ArgumentException("Value cannot be null or empty.", "GPA");
            if (ModelState.IsValid)
            {
                if (result != null)
                {
                    _resultService.SaveResult(result);
                }
            }
            else
            {
                ModelState.AddModelError("", "Invlid");
            }
            IList<ResultModel> results = _resultService.GetResults();
            ViewData["results"] = results;
            return View();
        }
        public ActionResult Remove(string id)
        {
            if (!string.IsNullOrEmpty(id))
            {
                _resultService.RemoveResult(id);
            }
            IList<ResultModel> results = _resultService.GetResults();
            ViewData["results"] = results;
            return View("Save");            
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Simplexhub
Bangladesh Bangladesh
** I have been working in the information technology field, specializing in web development(mostly .NET), internet marketing, usability, and high profile website design.

Comments and Discussions