public ActionResult Create(ViewModels.CategoryCreateViewModel model) { if (!ModelState.IsValid) { return(View(model)); } using (var db = new EcommerceModel()) { var cat = new Models.CategoryModel { Name = model.Name, }; db.Categories.Add(cat); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult CreateCategory(ViewModels.CategoryCreateViewModel model) { if (!ModelState.IsValid) { return(View(model)); } using (var db = new Models.DBModel()) { var category = new Models.ProductCategory { id = model.id, name = model.name }; db.ProductCategories.Add(category); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult CategoryCreate(ViewModels.CategoryCreateViewModel model) { if (!ModelState.IsValid) { return(View(model)); } using (var db = new Models.FazerDB()) { var category = new Models.Category { Name = model.Name }; db.Categories.Add(category); db.SaveChanges(); } return(RedirectToAction("CategoryIndex")); }
public ActionResult CategoryCreate() { var model = new ViewModels.CategoryCreateViewModel(); return(View(model)); }