public ActionResult AddItem(int? itemTypeId)
 {
     if (Session["isAdmin"] == null || !(bool)Session["isAdmin"])
         return RedirectToAction("Index", new { controller = "Home", action = "Index" });
     if (itemTypeId == null)
     {
         return HttpNotFound();
     }
     ItemTypes itemType = db.ItemTypes.Find(itemTypeId);
     if(itemType != null)
     {
         var newItem = new Items { ItemTypeId = (int)itemTypeId};
         db.Items.Add(newItem);
         db.SaveChanges();
     }
     return RedirectToAction("Edit", new RouteValueDictionary(new { action = "Edit", id = itemTypeId }));
 }
 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");
 }