public ActionResult SetSupply(SetSupplyViewModel viewModel) { var result = supplySlots.Update(viewModel.SupplySlotId, viewModel.SupplyId); if (result.Success) { return(RedirectToAction("Supplies", new { id = viewModel.PrinterId })); } else { AddModelStateErrors(result); } viewModel.CompatibleSupplies = SuppliesToSelectList(supplies.GetCompatibleNotInUse(viewModel.PrinterModelId)); return(View(viewModel)); }
// GET: Printers/SetSupply/5 public ActionResult SetSupply(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var supplySlot = supplySlots.GetById((int)id); if (supplySlot == null) { return(HttpNotFound()); } var viewModel = new SetSupplyViewModel(supplySlot); viewModel.CompatibleSupplies = SuppliesToSelectList(supplies.GetCompatibleNotInUse(viewModel.PrinterModelId)); return(View(viewModel)); }