//
 // GET: /SubCategoryManager/Create
 public ActionResult Create()
 {
     var viewModel = new SubCategoryManagerViewModel
     {
         SubCategory = new SubCategoryMaster(),
         Categories = shopDB.CategoryMasters.ToList()
     };
     return View(viewModel);
 }
        public ActionResult Create(SubCategoryMaster SubCategory)
        {
            if (ModelState.IsValid)
            {
                //Save Sub Category
                shopDB.AddToSubCategoryMasters(SubCategory);
                shopDB.SaveChanges();

                return RedirectToAction("Index");
            }
            // Invalid – redisplay with errors
            var viewModel = new SubCategoryManagerViewModel
            {
                SubCategory = new SubCategoryMaster(),
                Categories = shopDB.CategoryMasters.ToList()
            };
            return View(viewModel);
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            var subCategory = shopDB.SubCategoryMasters.Single(s => s.SubCategoryId == id);

            try
            {
                // TODO: Add update logic here
                UpdateModel(subCategory, "SubCategory");
                shopDB.SaveChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                var viewModel = new SubCategoryManagerViewModel
                {
                    SubCategory = shopDB.SubCategoryMasters.Single(s => s.SubCategoryId == id),
                    Categories = shopDB.CategoryMasters.ToList()
                };
                return View(viewModel);
            }
        }
 //
 // GET: /SubCategoryManager/Edit/5
 public ActionResult Edit(int id)
 {
     var viewModel = new SubCategoryManagerViewModel
     {
         SubCategory = shopDB.SubCategoryMasters.Single(s => s.SubCategoryId == id),
         Categories = shopDB.CategoryMasters.ToList()
     };
     return View(viewModel);
 }