public ActionResult Edit(int id, IFormCollection collection) { try { if (collection["ComputerType"] == "Desktop PC") { computerPersistenceService.Edit( new Computer { Id = int.Parse(collection["Id"]), ComputerType = collection["ComputerType"], Processor = collection["Processor"], Brand = collection["Brand"], UsbPorts = int.Parse(collection["UsbPorts"]), RamSlots = int.Parse(collection["RamSlots"]), FormFactor = collection["FormFactor"], Quantity = int.Parse(collection["Quantity"]) }); } else { laptopPersistenceService.Edit( new Laptop { Id = int.Parse(collection["Id"]), ComputerType = collection["ComputerType"], Processor = collection["Processor"], Brand = collection["Brand"], UsbPorts = int.Parse(collection["UsbPorts"]), RamSlots = int.Parse(collection["RamSlots"]), FormFactor = collection["FormFactor"], Quantity = int.Parse(collection["Quantity"]), ScreenSize = collection["ScreenSize"] }); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }