[6246] | 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 |
|
---|
[6317] | 9 | namespace HLWebOKBAdminPlugin.Controllers {
|
---|
| 10 | public class AlgorithmClassController : Controller {
|
---|
| 11 | //
|
---|
| 12 | // GET: /AlgorithmClass/
|
---|
[6246] | 13 |
|
---|
[6317] | 14 | public ActionResult Index() {
|
---|
[6290] | 15 |
|
---|
[6317] | 16 | Session["SelectedSubMenu"] = "AlgorithmClass";
|
---|
| 17 | AlgorithmClassModel acm = new AlgorithmClassModel();
|
---|
| 18 | return View(acm);
|
---|
| 19 | }//Index
|
---|
[6246] | 20 |
|
---|
[6317] | 21 | public ActionResult Detail(long? id) {
|
---|
| 22 | Session["SelectedSubMenu"] = "AlgorithmClass";
|
---|
| 23 | AlgorithmClassModel acm = new AlgorithmClassModel();
|
---|
[6246] | 24 |
|
---|
[6317] | 25 | if (id == null)
|
---|
| 26 | acm.AlgorithmClass = new AlgorithmClass();
|
---|
| 27 | else
|
---|
| 28 | acm.AlgorithmClass = (AlgorithmClass)acm.AlgorithmClasses.Where(x => x.Id.Equals((long)id)).FirstOrDefault();
|
---|
| 29 | return View(acm);
|
---|
| 30 | }//Detail
|
---|
[6246] | 31 |
|
---|
[6317] | 32 | /// <summary>
|
---|
| 33 | /// Controller for Index View
|
---|
| 34 | /// </summary>
|
---|
| 35 | /// <returns></returns>
|
---|
| 36 | public ActionResult Delete(long? id) {
|
---|
| 37 | Session["SelectedSubMenu"] = "AlgorithmClass";
|
---|
[6246] | 38 |
|
---|
[6317] | 39 | AlgorithmClassModel acm = new AlgorithmClassModel();
|
---|
| 40 | if (id != 0) {
|
---|
| 41 | acm.DeleteAlgorithmClass((long)id);
|
---|
| 42 | }
|
---|
| 43 | return View("Index", acm);
|
---|
| 44 | }//Delete
|
---|
[6246] | 45 |
|
---|
[6317] | 46 | /// <summary>
|
---|
| 47 | /// Controller for Detail View
|
---|
| 48 | /// </summary>
|
---|
| 49 | /// <returns></returns>
|
---|
| 50 | public ActionResult SaveChanges(FormCollection collection) {
|
---|
| 51 | long algorithmClassId = long.Parse(collection.Get("AlgorithmClassId"));
|
---|
| 52 | String algorithmClassName = collection.Get("AlgorithmClassName");
|
---|
| 53 | String algorithmClassDescription = collection.Get("AlgorithmClassDescription");
|
---|
[6246] | 54 |
|
---|
[6317] | 55 | // Later, we will get the runs from the session ...
|
---|
| 56 | AlgorithmClassModel acm = new AlgorithmClassModel();
|
---|
| 57 | if (algorithmClassId != 0)
|
---|
| 58 | acm.AlgorithmClass = (AlgorithmClass)acm.AlgorithmClasses.Where(x => x.Id.Equals(algorithmClassId)).FirstOrDefault();
|
---|
[6246] | 59 |
|
---|
[6317] | 60 | acm.AlgorithmClass.Name = algorithmClassName;
|
---|
| 61 | acm.AlgorithmClass.Description = algorithmClassDescription;
|
---|
[6246] | 62 |
|
---|
[6317] | 63 | acm.SaveAlgorithmClass(acm.AlgorithmClass);
|
---|
[6246] | 64 |
|
---|
[6317] | 65 | return View("Index", acm);
|
---|
| 66 | }//SaveChanges
|
---|
[6246] | 67 |
|
---|
[6317] | 68 | /// <summary>
|
---|
| 69 | /// Controller for Index View
|
---|
| 70 | /// </summary>
|
---|
| 71 | /// <returns></returns>
|
---|
| 72 | public ActionResult SortAsc() {
|
---|
| 73 | Session["SelectedSubMenu"] = "AlgorithmClass";
|
---|
| 74 | AlgorithmClassModel acm = new AlgorithmClassModel();
|
---|
| 75 | acm.AlgorithmClasses = acm.AlgorithmClasses.OrderBy(x => x.Name).ToList<AlgorithmClass>();
|
---|
| 76 | return View("Index", acm);
|
---|
| 77 | }
|
---|
[6246] | 78 |
|
---|
[6317] | 79 | /// <summary>
|
---|
| 80 | /// Controller for Index View
|
---|
| 81 | /// </summary>
|
---|
| 82 | /// <returns></returns>
|
---|
| 83 | public ActionResult SortDesc() {
|
---|
| 84 | Session["SelectedSubMenu"] = "AlgorithmClass";
|
---|
| 85 | AlgorithmClassModel acm = new AlgorithmClassModel();
|
---|
[6246] | 86 |
|
---|
[6317] | 87 | IOrderedEnumerable<AlgorithmClass> acmOrderedList = acm.AlgorithmClasses.OrderByDescending(x => x.Name);
|
---|
| 88 | IList<AlgorithmClass> acmList = new List<AlgorithmClass>();
|
---|
| 89 | foreach (var item in acmOrderedList) {
|
---|
| 90 | acmList.Add(item);
|
---|
| 91 | }
|
---|
| 92 | acm.AlgorithmClasses = acmList;
|
---|
[6246] | 93 |
|
---|
[6317] | 94 | // this should be the right code
|
---|
| 95 | //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>();
|
---|
| 96 | return View("Index", acm);
|
---|
| 97 | }
|
---|
[6246] | 98 |
|
---|
[6317] | 99 | }
|
---|
[6246] | 100 | }
|
---|
| 101 |
|
---|
[6317] | 102 |
|
---|