Changeset 6317 for branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/PlatformController.cs
- Timestamp:
- 05/27/11 19:09:49 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/PlatformController.cs
r6313 r6317 7 7 using HLWebOKBAdminPlugin.OKBAdministrationService; 8 8 9 namespace HLWebOKBAdminPlugin.Controllers 10 { 11 public class PlatformController : Controller 12 { 13 // 14 // GET: /Platform/ 9 namespace HLWebOKBAdminPlugin.Controllers { 10 public class PlatformController : Controller { 11 // 12 // GET: /Platform/ 15 13 16 public ActionResult Index() 17 { 18 Session["SelectedSubMenu"] = "Platform"; 19 PlatformModel plm = new PlatformModel(); 20 return View(plm); 21 }//Index 14 public ActionResult Index() { 15 Session["SelectedSubMenu"] = "Platform"; 16 PlatformModel plm = new PlatformModel(); 17 return View(plm); 18 }//Index 22 19 23 20 24 25 26 21 public ActionResult Detail(long? id) { 22 Session["SelectedSubMenu"] = "Platform"; 23 PlatformModel plm = new PlatformModel(); 27 24 28 29 30 31 32 33 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 34 31 35 36 32 public ActionResult Delete(long? id) { 33 Session["SelectedSubMenu"] = "Platform"; 37 34 38 39 40 41 42 43 35 PlatformModel plm = new PlatformModel(); 36 if (id != 0) { 37 plm.DeletePlatform((long)id); 38 } 39 return View("Index", plm); 40 }//Delete 44 41 45 46 47 48 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"); 49 46 50 51 52 53 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(); 54 51 55 56 52 plm.Platform.Name = platformName; 53 plm.Platform.Description = platformDescription; 57 54 58 55 plm.SavePlatform(plm.Platform); 59 56 60 61 57 return View("Index", plm); 58 }//SaveChanges 62 59 63 64 65 66 67 68 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 } 69 66 70 71 72 73 74 75 76 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(); 77 74 78 79 80 81 82 83 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; 84 81 85 // this should be the right code 86 //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>(); 87 return View("Index", plm); 88 } 82 // this should be the right code 83 //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>(); 84 return View("Index", plm); 89 85 } 86 } 90 87 }
Note: See TracChangeset
for help on using the changeset viewer.