Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1433 code formatted

File size: 2.7 KB
RevLine 
[6310]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using System.Web.Mvc;
6using HLWebOKBAdminPlugin.Models;
7using HLWebOKBAdminPlugin.OKBAdministrationService;
8
[6317]9namespace 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}
Note: See TracBrowser for help on using the repository browser.