//[CheckReferrer] public virtual async Task <ActionResult> Edit(EditRoleViewModel viewModel) { if (await _roleManager.CheckRoleIsSystemRoleAsync(viewModel.Id)) { return(Content("system")); } if (_roleManager.CheckForExisByName(viewModel.Name, viewModel.Id)) { this.AddErrors("Name", "این گروه قبلا در سیستم ثبت شده است"); } if (!ModelState.IsValid) { _roleManager.FillForEdit(viewModel); return(new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.Role.Views._Edit, viewModel) } }); } if (!await _roleManager.IsInDb(viewModel.Id)) { return(HttpNotFound()); } if (!await _roleManager.EditRole(viewModel)) { this.AddErrors("Name", "برای گروه کاربری مورد نظر ، دسترسی تعیین کنید"); _roleManager.FillForEdit(viewModel); return(new JsonNetResult { Data = new { success = false, View = this.RenderPartialViewToString(MVC.Role.Views._Edit, viewModel) } }); } await _unitOfWork.SaveAllChangesAsync(); var editedRole = await _roleManager.GetRole(viewModel.Id); return(new JsonNetResult { Data = new { success = true, View = this.RenderPartialViewToString(MVC.Role.Views._RoleItem, editedRole) } }); }
public virtual async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (await _roleManager.CheckRoleIsSystemRoleAsync(id.Value)) { ViewBag.ErrorMessage = "این گروه کاربری سیستمی است و حذف آن باعث اختلال در سیستم خواهد شد"; return(RedirectToAction("Index", "Role")); } await _roleManager.RemoveById(id.Value); ViewBag.Message = "گروه مورد نظر با موفقیت حذف شد"; return(RedirectToAction("Index", "Role")); }
public virtual async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (await _roleManager.CheckRoleIsSystemRoleAsync(id.Value)) { this.NotyWarning("این گروه کاربری سیستمی است و حذف آن باعث اختلال در سیستم خواهد شد"); return(RedirectToAction(MVC.Administrator.Role.ActionNames.List, MVC.Administrator.Role.Name)); } await _roleManager.RemoveById(id.Value); this.NotySuccess("گروه مورد نظر با موفقیت حذف شد"); return(RedirectToAction(MVC.Administrator.Role.ActionNames.List, MVC.Administrator.Role.Name)); }