// GET: Project/Create public ActionResult Create() { //create a List of objects through calling your service //Store that List in a Viewbag as one of 3-4 parameters of a SelectList object //@Html.DropDownList() in your view var cpuDb = new CPUService(); ViewBag.CpuId = new SelectList(cpuDb.GetAllCPUs().ToList(), "CpuId", "Name"); var memDb = new MemoryService(); ViewBag.MemoryId = new SelectList(memDb.GetAllMemories().ToList(), "MemoryId", "Name"); var caseDb = new CaseService(); ViewBag.CaseId = new SelectList(caseDb.GetAllCases().ToList(), "CaseId", "Name"); var videoDb = new VideoCardService(); ViewBag.VideoId = new SelectList(videoDb.GetAllVideoCards().ToList(), "VideoId", "Name"); var mobaDb = new MOBAService(); ViewBag.MotherboardId = new SelectList(mobaDb.GetAllMOBAs().ToList(), "MotherboardId", "Name"); var psuDb = new PSUService(); ViewBag.PsuId = new SelectList(psuDb.GetAllPowerSupplyUnits().ToList(), "PsuId", "Name"); return(View()); }
// GET: MOBA/Edit/5 public ActionResult Edit(int id) { var service = new MOBAService(); var detail = service.GetMOBAById(id); var model = new MOBAEdit { MotherboardId = detail.MotherboardId, Name = detail.Name, Manufacturer = detail.Manufacturer, Socket = detail.Socket, FormFactor = detail.FormFactor, MemoryMax = detail.MemoryMax, MemorySlots = detail.MemorySlots, Color = detail.Color, Chipset = detail.Chipset, PCIEX16Slots = detail.PCIEX16Slots, PCIEX8Slots = detail.PCIEX8Slots, PCIEX4Slots = detail.PCIEX4Slots, PCISlots = detail.PCISlots, EthernetPorts = detail.EthernetPorts, M2Slots = detail.M2Slots, Sata3GBsPorts = detail.Sata3GBsPorts, Sata6GBsPorts = detail.Sata6GBsPorts, SataExpressPorts = detail.MSataSlots, OnboardVideo = detail.OnboardVideo, OnboardUSB3Headers = detail.OnboardUSB3Headers, WifiNetworking = detail.WifiNetworking, IsAvailable = detail.IsAvailable, }; return(View(model)); }
// GET: MOBA/Details/5 public ActionResult Details(int id) { var service = new MOBAService(); var model = service.GetMOBAById(id); return(View(model)); }
// GET: MOBA public ActionResult Index() { var service = new MOBAService(); var mobaList = service.GetAllMOBAs(); return(View(mobaList)); }
public ActionResult DeleteMOBA(int id) { var service = new MOBAService(); service.DeleteMOBA(id); TempData["SaveResult"] = "Your Motherboard entry was deleted."; return(RedirectToAction("Index")); }
public ActionResult Create(MOBACreate moba) { var service = new MOBAService(); if (ModelState.IsValid) { service.CreateMOBA(moba); return(RedirectToAction("Index")); } return(View(moba)); }
// GET: MOBA/Delete/5 public ActionResult Delete(int id) { var service = new MOBAService(); var model = service.GetMOBAById(id); if (model == null) { return(HttpNotFound()); } return(View(model)); }
// GET: Project/Edit/5 public ActionResult Edit(int id) { var cpuDb = new CPUService(); ViewBag.CpuId = new SelectList(cpuDb.GetAllCPUs().ToList(), "CpuId", "Name"); var memDb = new MemoryService(); ViewBag.MemoryId = new SelectList(memDb.GetAllMemories().ToList(), "MemoryId", "Name"); var caseDb = new CaseService(); ViewBag.CaseId = new SelectList(caseDb.GetAllCases().ToList(), "CaseId", "Name"); var videoDb = new VideoCardService(); ViewBag.VideoId = new SelectList(videoDb.GetAllVideoCards().ToList(), "VideoId", "Name"); var mobaDb = new MOBAService(); ViewBag.MotherboardId = new SelectList(mobaDb.GetAllMOBAs().ToList(), "MotherboardId", "Name"); var psuDb = new PSUService(); ViewBag.PsuId = new SelectList(psuDb.GetAllPowerSupplyUnits().ToList(), "PsuId", "Name"); var service = new ProjectService(); var detail = service.GetProjectById(id); var model = new ProjectEdit { ProjectId = detail.ProjectId, Name = detail.Name, Description = detail.Description, Notes = detail.Notes, CpuId = detail.CpuId, CPU = detail.CPU, MemoryId = detail.MemoryId, Memory = detail.Memory, CaseId = detail.CaseId, Case = detail.Case, VideoId = detail.VideoId, VideoCard = detail.VideoCard, MotherboardId = detail.MotherboardId, Motherboard = detail.Motherboard, PsuId = detail.PsuId, PowerSupplyUnit = detail.PowerSupplyUnit }; return(View(model)); }
public ActionResult Edit(int id, MOBAEdit model) { if (model.MotherboardId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = new MOBAService(); if (service.UpdateMOBA(model)) { TempData["SaveResult"] = "Your Motherboard information was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your Motherboard information could not be updated."); return(View()); }