[6130] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Web;
|
---|
| 5 | using System.Web.Mvc;
|
---|
| 6 | using HLWebOKBAdminPlugin.Models;
|
---|
| 7 | using HLWebOKBAdminPlugin.OKBAdministrationService;
|
---|
| 8 |
|
---|
| 9 | namespace HLWebOKBAdminPlugin.Controllers
|
---|
| 10 | {
|
---|
| 11 | /// <summary>
|
---|
| 12 | /// Controller for Problem Submenu
|
---|
| 13 | /// </summary>
|
---|
| 14 | public class ProblemController : Controller
|
---|
| 15 | {
|
---|
| 16 | /// <summary>
|
---|
| 17 | /// Controller for Index View
|
---|
| 18 | /// </summary>
|
---|
| 19 | /// <returns></returns>
|
---|
| 20 | public ActionResult Index()
|
---|
| 21 | {
|
---|
| 22 | Session["SelectedSubMenu"] = "Problem";
|
---|
| 23 | ProblemModel pm = new ProblemModel();
|
---|
| 24 | return View(pm);
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | /// <summary>
|
---|
| 28 | /// Controller for Detail View
|
---|
| 29 | /// </summary>
|
---|
| 30 | /// <param name="p"></param>
|
---|
| 31 | /// <returns></returns>
|
---|
| 32 | public ActionResult Detail(long id)
|
---|
| 33 | {
|
---|
| 34 | Session["SelectedSubMenu"] = "Problem";
|
---|
| 35 | // We use here the ProblemMode, but I think
|
---|
| 36 | // we can also use the Problem class. (?)
|
---|
| 37 | ProblemModel pm = new ProblemModel();
|
---|
[6142] | 38 | if(id == 0)
|
---|
| 39 | pm.Problem = new Problem();
|
---|
| 40 | else
|
---|
| 41 | pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals(id)).FirstOrDefault();
|
---|
[6130] | 42 | return View(pm);
|
---|
| 43 | }
|
---|
| 44 |
|
---|
[6142] | 45 | public ActionResult SaveChanges(FormCollection collection) {
|
---|
| 46 | long problemId = long.Parse(collection.Get("ProblemId"));
|
---|
| 47 | String problemName = collection.Get("ProblemName");
|
---|
| 48 | String problemDescription = collection.Get("ProblemDescription");
|
---|
| 49 | String problemDataTypeName = collection.Get("ProblemDataTypeName");
|
---|
| 50 | long problemClassId = long.Parse(collection.Get("ProblemClassId"));
|
---|
| 51 | long plattformId = long.Parse(collection.Get("PlattformId"));
|
---|
| 52 |
|
---|
| 53 | // Later, we will get the runs from the session ...
|
---|
| 54 | ProblemModel pm = new ProblemModel();
|
---|
| 55 | pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals(problemId)).FirstOrDefault();
|
---|
| 56 |
|
---|
| 57 | pm.Problem.Name = problemName;
|
---|
| 58 | pm.Problem.Description = problemDescription;
|
---|
| 59 | pm.Problem.DataTypeName = problemDataTypeName;
|
---|
| 60 | pm.Problem.ProblemClassId = problemClassId;
|
---|
| 61 | pm.Problem.PlatformId = plattformId;
|
---|
| 62 |
|
---|
| 63 | pm.SaveProblem(pm.Problem);
|
---|
| 64 |
|
---|
| 65 | return View("Index",pm);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | //public ActionResult CreateProblem(FormCollection collection) {
|
---|
| 69 | // Problem problem = new Problem();
|
---|
| 70 | // String problemName = collection.Get("ProblemName");
|
---|
| 71 | // long problemClassId = long.Parse(collection.Get("ProblemClassId"));
|
---|
| 72 | // long plattformId = long.Parse(collection.Get("PlattformId"));
|
---|
| 73 | // problem.Name = problemName;
|
---|
| 74 | // problem.ProblemClassId = problemClassId;
|
---|
| 75 | // problem.PlatformId = plattformId;
|
---|
| 76 | // problem.DataTypeName = "";
|
---|
| 77 | // problem.DataTypeTypeName = "";
|
---|
| 78 | // problem.Description = "";
|
---|
| 79 |
|
---|
| 80 | // // Later, we will get the runs from the session ..
|
---|
| 81 | // ProblemModel pm = new ProblemModel();
|
---|
| 82 | // pm.CreateProblem(problem);
|
---|
| 83 |
|
---|
| 84 | // return View("Index", pm);
|
---|
| 85 | //}
|
---|
| 86 |
|
---|
[6130] | 87 | }
|
---|
| 88 | }
|
---|