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"));
 }
Esempio n. 2
0
 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"));
 }
Esempio n. 3
0
        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"));
        }
Esempio n. 4
0
        public ActionResult CategoryCreate()
        {
            var model = new ViewModels.CategoryCreateViewModel();

            return(View(model));
        }