Пример #1
0
        public ActionResult CreateCategory(Category category)
        {
            if (_categoryService.GetAll().Count(c => c.Name == category.Name) > 0)
                return RedirectToAction("Create",
                        new RouteValueDictionary {
                            { "id", null},
                            { "createError", true } });

            if (ModelState.IsValid)
            {
                _categoryService.Insert(category);
                return RedirectToAction("Index");
            }
            return View(category);
        }
Пример #2
0
        public ActionResult Delete(int id, Category model)
        {
            try
            {
                    var category = _categoryService.GetById(id);
                    _categoryService.Delete(category);
            }
            catch (DataException)
            {

                return RedirectToAction("Delete",
                    new RouteValueDictionary {
                        { "id", id },
                        { "saveChangesError", true } });
            }

            return RedirectToAction("Index");
        }
Пример #3
0
 public void Update(Category model)
 {
     if (model == null)
         throw new ArgumentNullException("category");
     categoryRepository.Update(model);
 }
Пример #4
0
        public ActionResult Edit(Category model)
        {
            if (ModelState.IsValid)
            {
                _categoryService.Update(model);

                return RedirectToAction("Index");
            }

            return View(model);
        }