public ActionResult SubmitInventoryLocations(ItemsMissingInventoryLocationViewModel vm)
 {
     if (Session["isAdmin"] == null || !(bool)Session["isAdmin"])
         return RedirectToAction("Index", new { controller = "Home", action = "Index" });
     if (vm == null)
         return RedirectToAction("Index");
     for (int i = 0; i < vm.ItemsMissingLocation.Count; i++)
     {
         var dbItem = db.Items.Find(vm.ItemsMissingLocation[i].ItemId);
         if (dbItem == null)
         {
             TempData["error"] = "Could not find item";
             return RedirectToAction("Index");
         }
         dbItem.InventoryLocationId = vm.ItemsMissingLocation[i].InventoryLocationId;
         db.Entry(dbItem).State = EntityState.Modified;
         db.SaveChanges();
     }
     return RedirectToAction("Index");
 }
 public ActionResult NoInventoryLocation()
 {
     if (Session["isAdmin"] == null || !(bool)Session["isAdmin"])
         return RedirectToAction("Index", new { controller = "Home", action = "Index" });
     var noInventoryLocationItems = db.Items.Where(item => item.InventoryLocationId == null);
     if (noInventoryLocationItems.ToList().Count == 0)
     {
         TempData["error"] = "No items exist without an inventory location";
         return RedirectToAction("Index");
     }
     IList<SelectListItem> inventoryLocations = db.InventoryLocations.Select(x => new SelectListItem
     {
         Text = x.InventoryLocationName,
         Value = x.InventoryLocationId.ToString()
     }).ToList();
     inventoryLocations.Insert(0, new SelectListItem { Text = "", Value = null });
     IList<IEnumerable<SelectListItem>> InvLocSelectLists = new List<IEnumerable<SelectListItem>>();
     foreach (var item in noInventoryLocationItems)
     {
         IList<SelectListItem> currLabelList = new List<SelectListItem>();    //Create Copy of list
         foreach (var location in inventoryLocations)
             currLabelList.Add(new SelectListItem { Text = location.Text, Value = location.Value });
         InvLocSelectLists.Add(currLabelList);
     }
     ItemsMissingInventoryLocationViewModel vm = new ItemsMissingInventoryLocationViewModel
     {
         ItemsMissingLocation = noInventoryLocationItems.OrderBy(item => item.ItemType.ItemName).ToList(),
         InventoryLocations = InvLocSelectLists
     };
     return View(vm);
 }