コード例 #1
0
 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"));
 }
コード例 #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"));
 }
コード例 #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"));
        }
コード例 #4
0
ファイル: ProductController.cs プロジェクト: cRIPSTER/inlupp
        public ActionResult CategoryCreate()
        {
            var model = new ViewModels.CategoryCreateViewModel();

            return(View(model));
        }