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