public ActionResult Delete(RoleEditingViewModel model) { var isSucceed = _roleDeletingPersistence.RemoveRole(model.RoleId.Value); if (isSucceed) { SetSucceedMessage("Role removed successfully !"); //update cach : AppCach.AllRoles.Except(AppCach.AllRoles.Where(r => r.Id == roleId)); AppCach.AllRoles = new ConcurrentBag <Role>(_roleRepository.GetRoles()); } else { SetErrorMessage("Cannot delete role"); return(View()); } return(RedirectToAction("Index", "Role")); }
public ActionResult Edit(RoleEditingViewModel viewModel) { if (!ModelState.IsValid) { SetErrorMessage("Please, validate all fields"); return(View(viewModel)); } var role = PrepareRole(viewModel, false); if (_roleEditingPersistence.SaveRole(role)) { SetSucceedMessage("Save role successfully"); } else { SetErrorMessage("Cannot update role"); } return(RedirectToAction("Index", "Role")); }