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 | public class PlatformController : Controller
|
---|
12 | {
|
---|
13 | //
|
---|
14 | // GET: /Platform/
|
---|
15 |
|
---|
16 | public ActionResult Index()
|
---|
17 | {
|
---|
18 | Session["SelectedSubMenu"] = "Platform";
|
---|
19 | PlatformModel plm = new PlatformModel();
|
---|
20 | return View(plm);
|
---|
21 | }//Index
|
---|
22 |
|
---|
23 |
|
---|
24 | public ActionResult Detail(long? id) {
|
---|
25 | Session["SelectedSubMenu"] = "Platform";
|
---|
26 | PlatformModel plm = new PlatformModel();
|
---|
27 |
|
---|
28 | if (id == null)
|
---|
29 | plm.Platform = new Platform();
|
---|
30 | else
|
---|
31 | plm.Platform = (Platform)plm.Platforms.Where(x => x.Id.Equals((long)id)).FirstOrDefault();
|
---|
32 | return View(plm);
|
---|
33 | }//Detail
|
---|
34 |
|
---|
35 | public ActionResult Delete(long? id) {
|
---|
36 | Session["SelectedSubMenu"] = "Platform";
|
---|
37 |
|
---|
38 | PlatformModel plm = new PlatformModel();
|
---|
39 | if (id != 0) {
|
---|
40 | plm.DeletePlatform((long)id);
|
---|
41 | }
|
---|
42 | return View("Index", plm);
|
---|
43 | }//Delete
|
---|
44 |
|
---|
45 | public ActionResult SaveChanges(FormCollection collection) {
|
---|
46 | long platformId = long.Parse(collection.Get("PlatformId"));
|
---|
47 | String platformName = collection.Get("PlatformName");
|
---|
48 | String platformDescription = collection.Get("PlatformDescription");
|
---|
49 |
|
---|
50 | // Later, we will get the runs from the session ...
|
---|
51 | PlatformModel plm = new PlatformModel();
|
---|
52 | if (platformId != 0)
|
---|
53 | plm.Platform = (Platform)plm.Platforms.Where(x => x.Id.Equals(platformId)).FirstOrDefault();
|
---|
54 |
|
---|
55 | plm.Platform.Name = platformName;
|
---|
56 | plm.Platform.Description = platformDescription;
|
---|
57 |
|
---|
58 | plm.SavePlatform(plm.Platform);
|
---|
59 |
|
---|
60 | return View("Index", plm);
|
---|
61 | }//SaveChanges
|
---|
62 |
|
---|
63 | public ActionResult SortAsc() {
|
---|
64 | Session["SelectedSubMenu"] = "Platform";
|
---|
65 | PlatformModel plm = new PlatformModel();
|
---|
66 | plm.Platforms = plm.Platforms.OrderBy(x => x.Name).ToList<Platform>();
|
---|
67 | return View("Index", plm);
|
---|
68 | }
|
---|
69 |
|
---|
70 | /// <summary>
|
---|
71 | /// Controller for Index View
|
---|
72 | /// </summary>
|
---|
73 | /// <returns></returns>
|
---|
74 | public ActionResult SortDesc() {
|
---|
75 | Session["SelectedSubMenu"] = "Platform";
|
---|
76 | PlatformModel plm = new PlatformModel();
|
---|
77 |
|
---|
78 | IOrderedEnumerable<Platform> plmOrderedList = plm.Platforms.OrderByDescending(x => x.Name);
|
---|
79 | IList<Platform> plmList = new List<Platform>();
|
---|
80 | foreach (var item in plmOrderedList) {
|
---|
81 | plmList.Add(item);
|
---|
82 | }
|
---|
83 | plm.Platforms = plmList;
|
---|
84 |
|
---|
85 | // this should be the right code
|
---|
86 | //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>();
|
---|
87 | return View("Index", plm);
|
---|
88 | }
|
---|
89 | }
|
---|
90 | }
|
---|