Example #1
0
        public virtual ActionResult Edit(int id)
        {
            var category = _categoryService.GetCategory(id);

            var model = new EditCategoryViewModel { Category = category };
            return View(model);
        }
Example #2
0
        public virtual ActionResult Edit(EditCategoryViewModel model)
        {
            if (string.IsNullOrWhiteSpace(model.Category.Name))
            {
                ModelState.AddModelError("Category.Name", "Name is required");
            }

            if (model.Category.ReOrder < 1)
            {
                ModelState.AddModelError("Category.ReOrder", "ReOrder Number must be bigger than 0");
            }

            if (ModelState.IsValid)
            {
                var result = _categoryService.Save(model.Category);

                if (result > 0)
                    return RedirectToAction(MVC.Admin.Category.Index());
            }

            return View("Edit", model);
        }
        public ActionResult EditCategory(EditCategoryViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                this.TempData["NotificationError"] = "Something is wrong, please try again later";
                return this.View(model);
            }

            this.categories.UpdateCategory(model.Id, model.Name);
            this.TempData["Notification"] = "You successfully update category";

            return this.RedirectToAction("Index");
        }
Example #4
0
 public virtual ActionResult Add()
 {
     var category = new EditCategoryViewModel { Category = new Category() };
     return View("Edit", category);
 }
        public ActionResult EditCategory(int id, string name)
        {
            var categoryToEdit = new EditCategoryViewModel
            {
                Id = id,
                Name = name
            };

            return this.PartialView("_EditCategoryPartial", categoryToEdit);
        }