public ActionResult Create(SubcategoryViewModel model)
 {
     if (ModelState.IsValid)
     {
         subcategoryService.Create(model);
         return RedirectToAction("List", "Subcategory");
     }
     return View(model);
 }
 public ActionResult Delete(SubcategoryViewModel model)
 {
     try
     {
         subcategoryService.Delete(model.SubcategoryId);
         return RedirectToAction("List", "Subcategory");
     }
     catch
     {
         return View();
     }
 }
 public void Create(SubcategoryViewModel model)
 {
     Subcategory subcategory = new Subcategory
     {
         CategoryId = model.CategoryId,
         SubcategoryName = model.SubcategoryName
     };
     using (var context = new WebShopMVCContext())
     {
         context.Subcategories.Add(subcategory);
         context.SaveChanges();
     }
 }
 public void Update(SubcategoryViewModel model)
 {
     using (var context = new WebShopMVCContext())
     {
         var subcategory = context.Subcategories.Find(model.SubcategoryId);
         subcategory.SubcategoryName = model.SubcategoryName;
         subcategory.CategoryId = model.CategoryId;
         context.SaveChanges();
     }
 }