Exemplo n.º 1
0
 public ActionResult Edit(AddOrEditCategoryViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         MainRepository.UpdateCategory(CurrentUser, new Category(){CategoryId = viewModel.CategoryId, Name = viewModel.Name, Description = viewModel.Description});
         return RedirectToAction("Index");
     }
     return View(viewModel);
 }
Exemplo n.º 2
0
 public ActionResult Edit(AddOrEditCategoryViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         MainRepository.UpdateCategory(CurrentUser, new Category()
         {
             CategoryId = viewModel.CategoryId, Name = viewModel.Name, Description = viewModel.Description
         });
         return(RedirectToAction("Index"));
     }
     return(View(viewModel));
 }
Exemplo n.º 3
0
        public ActionResult Add(AddOrEditCategoryViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var category = Mapper.Map <Category>(vm);
                if (CategoryService.Add(category) != 0)
                {
                    return(RedirectToAction("Index", "Dashboard"));
                }

                ModelState.AddModelError("", "An error occurred, category has not been created. Please contact the administrator.");
            }

            return(View(vm));
        }