public ActionResult MissingCategories(AdminCategoryMissingViewModel model, string[] selections)
        {
            if (ModelState.IsValid)
            {
                if (model.SelectedCategoryId == 0 || selections == null)
                {
                    return(View("Error"));
                }

                var catList = new List <Category>();

                foreach (var catName in selections)
                {
                    foreach (var cat in db.Categories.Where(m => m.Name == catName).ToList())
                    {
                        catList.Add(cat);
                    }
                }

                foreach (var cat in catList)
                {
                    cat.KL_CategoryId   = model.SelectedCategoryId;
                    db.Entry(cat).State = EntityState.Modified;
                }

                db.SaveChanges();
                return(RedirectToAction("Categories"));
            }
            return(RedirectToAction("MissingCategories"));
        }
        public ActionResult MissingCategories()
        {
            var model = new AdminCategoryMissingViewModel {
                AvailableCategories = new Dictionary <string, int>()
            };

            model.MissingCategories = db.Categories
                                      .Include(m => m.KL_Category)
                                      .Where(m => m.KL_Category.Name == "Other")
                                      .Select(m => m.Name)
                                      .Distinct()
                                      .ToList();

            foreach (var cat in db.KL_Categories.ToList())
            {
                model.AvailableCategories.Add(cat.Name, cat.Id);
            }
            return(View(model));
        }