Esempio n. 1
0
        public void EditCategory(CategoryViewModel category)
        {
            var query = db.Category.Where(x => x.id == category.id).First();

            query.name = category.name;
            db.SaveChanges();
        }
Esempio n. 2
0
 public ActionResult EditCategory(CategoryViewModel category)
 {
     if (ModelState.IsValid)
     {
         categoryModel.EditCategory(category);
     }
     return RedirectToAction("Index", "Category");
 }
Esempio n. 3
0
 public ActionResult CreateCategory(CategoryViewModel category)
 {
     if (ModelState.IsValid)
     {
         categoryModel.AddCategory(category);
         return RedirectToAction("Index", "Category");
     }
     return View(category);
 }
Esempio n. 4
0
        public void AddCategory(CategoryViewModel category)
        {
            Category newCategory = new Category()
            {
                name = category.name
            };

            db.Category.Add(newCategory);
            db.SaveChanges();
        }