public ActionResult Create(InventoryCategory category) { category.SortOrder = _context.InventoryCategories .Select(x => x.SortOrder) .DefaultIfEmpty() .ToList() .Max() + 1; if (ModelState.IsValid) { _context.Add(category); _context.SaveChanges(); TempData["SuccessMessage"] = "Inventory Category Created"; return(RedirectToAction(nameof(Index))); } return(View(category)); }
public ActionResult Create(StorageLocation location) { location.SortOrder = _context.StorageLocations .Select(x => x.SortOrder) .DefaultIfEmpty() .ToList() .Max() + 1; if (ModelState.IsValid) { _context.Add(location); _context.SaveChanges(); TempData["SuccessMessage"] = "Storage Location Created"; return(RedirectToAction(nameof(Index))); } return(View(location)); }
public ActionResult Create(Unit unit) { unit.SortOrder = _context.Units .Select(x => x.SortOrder) .DefaultIfEmpty() .ToList() .Max() + 1; if (ModelState.IsValid) { _context.Add(unit); _context.SaveChanges(); TempData["SuccessMessage"] = "Unit Created"; return(RedirectToAction(nameof(Index))); } return(View(unit)); }