예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }