public async Task <IActionResult> RestockFinal(RestockInventoryViewModel model, int id) { if (ModelState.IsValid) { try { var inventory = await _context.Inventories.FirstOrDefaultAsync(iv => iv.InventoryID == id); if (inventory != null) { inventory.Quantity = model.Quantity; inventory.CriticalLevel = model.Critical; inventory.InventoryDate = DateTime.Now; _context.Entry(inventory).State = EntityState.Modified; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException) { } } return(NotFound()); }
public async Task <IActionResult> Restock(int inventoryID) { var inventory = await _context.Inventories.FirstOrDefaultAsync(iv => iv.InventoryID == inventoryID); if (inventory != null) { RestockInventoryViewModel vm = new RestockInventoryViewModel(); var product = await _context.Products.FirstOrDefaultAsync(pd => pd.ProductID == inventory.ProductID); vm.InventoryID = inventoryID; vm.Critical = inventory.CriticalLevel; vm.Quantity = inventory.Quantity; vm.ProductName = product.ProductName; return(View(vm)); } return(NotFound()); }