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.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)