public IActionResult Details(string id) { if (id == null) { return(NotFound()); } var consumptionEvent = _eventService.GetConsumptionEvent(id, true); if (consumptionEvent == null) { return(NotFound()); } ConsumptionEventModel presentation = new ConsumptionEventModel() { ConsumptionEvent = consumptionEvent, InventoryItems = new List <InventoryItem>() { consumptionEvent.InventoryItemNavigation } }; return(View(presentation)); }
public IActionResult Edit(string id, ConsumptionEventModel vm) { if (id == null) { return(NotFound()); } var temp = _eventService.GetConsumptionEvent(id, true); if (temp != null) { vm.ConsumptionEvent.AddedBy = temp.AddedBy; vm.ConsumptionEvent.DateAdded = temp.DateAdded; vm.ConsumptionEvent.UpdatedBy = User.Identity.Name; vm.ConsumptionEvent.DateUpdated = DateTime.Now; } if (ModelState.IsValid) { _eventService.UpdateConsumptionEvent(vm.ConsumptionEvent, User); TempData["SuccessMessage"] = "Save Complete"; return(RedirectToAction()); } vm.ConsumptionEvent.UpdatedBy = temp.UpdatedBy; vm.ConsumptionEvent.DateUpdated = temp.DateUpdated; vm.InventoryItems = new List <InventoryItem>() { temp.InventoryItemNavigation }; return(View(vm)); }