using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using HLWebOKBAdminPlugin.Models; using HLWebOKBAdminPlugin.OKBAdministrationService; namespace HLWebOKBAdminPlugin.Controllers { /// /// Controller for Problem Submenu /// public class ProblemController : Controller { /// /// Controller for Index View /// /// public ActionResult Index() { Session["SelectedSubMenu"] = "Problem"; ProblemModel pm = new ProblemModel(); return View(pm); } /// /// Controller for Detail View /// /// /// public ActionResult Detail(long id) { Session["SelectedSubMenu"] = "Problem"; // We use here the ProblemMode, but I think // we can also use the Problem class. (?) ProblemModel pm = new ProblemModel(); if(id == 0) pm.Problem = new Problem(); else pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals(id)).FirstOrDefault(); return View(pm); } public ActionResult SaveChanges(FormCollection collection) { long problemId = long.Parse(collection.Get("ProblemId")); String problemName = collection.Get("ProblemName"); String problemDescription = collection.Get("ProblemDescription"); String problemDataTypeName = collection.Get("ProblemDataTypeName"); long problemClassId = long.Parse(collection.Get("ProblemClassId")); long plattformId = long.Parse(collection.Get("PlattformId")); // Later, we will get the runs from the session ... ProblemModel pm = new ProblemModel(); pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals(problemId)).FirstOrDefault(); pm.Problem.Name = problemName; pm.Problem.Description = problemDescription; pm.Problem.DataTypeName = problemDataTypeName; pm.Problem.ProblemClassId = problemClassId; pm.Problem.PlatformId = plattformId; pm.SaveProblem(pm.Problem); return View("Index",pm); } //public ActionResult CreateProblem(FormCollection collection) { // Problem problem = new Problem(); // String problemName = collection.Get("ProblemName"); // long problemClassId = long.Parse(collection.Get("ProblemClassId")); // long plattformId = long.Parse(collection.Get("PlattformId")); // problem.Name = problemName; // problem.ProblemClassId = problemClassId; // problem.PlatformId = plattformId; // problem.DataTypeName = ""; // problem.DataTypeTypeName = ""; // problem.Description = ""; // // Later, we will get the runs from the session .. // ProblemModel pm = new ProblemModel(); // pm.CreateProblem(problem); // return View("Index", pm); //} } }