Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AlgorithmClassController.cs @ 11813

Last change on this file since 11813 was 6317, checked in by jwolfing, 14 years ago

#1433 code formatted

File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.Web.Mvc;
6using HLWebOKBAdminPlugin.Models;
7using HLWebOKBAdminPlugin.OKBAdministrationService;
8
9namespace HLWebOKBAdminPlugin.Controllers {
10  public class AlgorithmClassController : Controller {
11    //
12    // GET: /AlgorithmClass/
13
14    public ActionResult Index() {
15
16      Session["SelectedSubMenu"] = "AlgorithmClass";
17      AlgorithmClassModel acm = new AlgorithmClassModel();
18      return View(acm);
19    }//Index
20
21    public ActionResult Detail(long? id) {
22      Session["SelectedSubMenu"] = "AlgorithmClass";
23      AlgorithmClassModel acm = new AlgorithmClassModel();
24
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
31
32    /// <summary>
33    /// Controller for Index View
34    /// </summary>
35    /// <returns></returns>
36    public ActionResult Delete(long? id) {
37      Session["SelectedSubMenu"] = "AlgorithmClass";
38
39      AlgorithmClassModel acm = new AlgorithmClassModel();
40      if (id != 0) {
41        acm.DeleteAlgorithmClass((long)id);
42      }
43      return View("Index", acm);
44    }//Delete
45
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");
54
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();
59
60      acm.AlgorithmClass.Name = algorithmClassName;
61      acm.AlgorithmClass.Description = algorithmClassDescription;
62
63      acm.SaveAlgorithmClass(acm.AlgorithmClass);
64
65      return View("Index", acm);
66    }//SaveChanges
67
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    }
78
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();
86
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;
93
94      // this should be the right code
95      //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>();
96      return View("Index", acm);
97    }
98
99  }
100}
101
102
Note: See TracBrowser for help on using the repository browser.