public ActionResult Add(int id)
 {
     if (Session["isAdmin"] == null || !(bool)Session["isAdmin"])
         return RedirectToAction("Index", new { controller = "Home", action = "Index" });
     var itemType = db.ItemTypes.Find(id);
     if (itemType == null)
         return RedirectToAction("Index");
     IList<SelectListItem> inventoryLocations = db.InventoryLocations.Select(x => new SelectListItem
     {
         Text = x.InventoryLocationName,
         Value = x.InventoryLocationId.ToString()
     }).OrderBy(listItem => listItem.Text).ToList();
     inventoryLocations.Insert(0, new SelectListItem { Text = "", Value = null });
     ItemTypesQuantityModel vm = new ItemTypesQuantityModel
     {
         ItemType = itemType,
         Quantity = 1,
         InventoryLocations = inventoryLocations
     };
     return View(vm);
 }
 public ActionResult AddItemQuantity(ItemTypesQuantityModel vm)
 {
     if (Session["isAdmin"] == null || !(bool)Session["isAdmin"])
         return RedirectToAction("Index", new { controller = "Home", action = "Index" });
     //if (ModelState.IsValid)
     //{
     var itemType = db.ItemTypes.Find(vm.ItemType.ItemTypeId);
     if (itemType == null)
         return RedirectToAction("Index");
     int? invLocId = vm.SelectedInventoryLocation;
     var invLocation = db.InventoryLocations.Find(invLocId);
     for (int i=0; i<vm.Quantity; i++)
     {
         var item = new Items { ItemTypeId = itemType.ItemTypeId };
         if (invLocation != null)
             item.InventoryLocationId = invLocId;
         db.Items.Add(item);
         db.SaveChanges();
     }
     //}
     return RedirectToAction("Index");
 }