Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/PlatformController.cs @ 9931

Last change on this file since 9931 was 6317, checked in by jwolfing, 13 years ago

#1433 code formatted

File size: 2.7 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 PlatformController : Controller {
11    //
12    // GET: /Platform/
13
14    public ActionResult Index() {
15      Session["SelectedSubMenu"] = "Platform";
16      PlatformModel plm = new PlatformModel();
17      return View(plm);
18    }//Index
19
20
21    public ActionResult Detail(long? id) {
22      Session["SelectedSubMenu"] = "Platform";
23      PlatformModel plm = new PlatformModel();
24
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
31
32    public ActionResult Delete(long? id) {
33      Session["SelectedSubMenu"] = "Platform";
34
35      PlatformModel plm = new PlatformModel();
36      if (id != 0) {
37        plm.DeletePlatform((long)id);
38      }
39      return View("Index", plm);
40    }//Delete
41
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");
46
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();
51
52      plm.Platform.Name = platformName;
53      plm.Platform.Description = platformDescription;
54
55      plm.SavePlatform(plm.Platform);
56
57      return View("Index", plm);
58    }//SaveChanges
59
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    }
66
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();
74
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;
81
82      // this should be the right code
83      //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>();
84      return View("Index", plm);
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.