Пример #1
0
        public ActionResult CreateCategory(CategoryViewModel model)
        {
            if (IsModelValidAndPersistErrors())
            {
                _categoryServices.CreateCategory(model.Name, model.Description);
                SetSuccess("Category created");
                return RedirectToAction("Forums");
            }

            return RedirectToSelf();
        }
Пример #2
0
        public ActionResult EditCategory(CategoryViewModel model)
        {
            if (IsModelValidAndPersistErrors())
            {
                Category category = _categoryRepository.Get(model.CategoryID);
                category.Name = model.Name;
                category.Description = model.Description;
                _categoryRepository.Update(category);
                SetSuccess("Category Updated");
                return RedirectToAction("Forums");
            }

            return RedirectToSelf();
        }
Пример #3
0
        public ActionResult CreateCategory()
        {
            CategoryViewModel model = new CategoryViewModel();

            return View(model);
        }
Пример #4
0
        public ActionResult EditCategory(int categoryID)
        {
            Category category = _categoryRepository.Get(categoryID);
            CategoryViewModel model = new CategoryViewModel()
            {
                CategoryID = category.CategoryID,
                Description = category.Description,
                Name = category.Name
            };

            return View(model);
        }