public async Task <ActionResult> Edit(RoleEditPostModel model) { if (ModelState.IsValid) { foreach (string UserId in model.MemberIdsToAdd ?? new string[] { }) { IdentityResult res = await UserManager.AddToRoleAsync(UserId, model.RoleName); if (!res.Succeeded) { AddErrorsToState(res); } } foreach (string UserId in model.MemberIdsToDelete ?? new string[] { }) { IdentityResult res = await UserManager.RemoveFromRoleAsync(UserId, model.RoleName); if (!res.Succeeded) { AddErrorsToState(res); } } return(RedirectToAction("Index")); } return(View("Error", new string[] { "Произошла ошибка" })); }
public IActionResult Edit(RoleEditPostModel model) { HttpResponseModel response = ResponseModelFactory.CreateInstance; using (this.DbContext) { if (this.DbContext.Role.Any(x => x.Name == model.Name && x.Id != model.Id)) { response.SetFailed("角色已存在"); return(this.Ok(response)); } Role entity = this.DbContext.Role.Find(model.Id); entity.Name = model.Name; entity.UpdateByUserId = 1; entity.UpdateByUserName = "******"; entity.UpdateTime = DateTime.Now; entity.Description = model.Description; if (model.IsEnable.HasValue) { entity.IsEnable = model.IsEnable.Value; } if (model.IsForbidden.HasValue) { entity.IsForbidden = model.IsForbidden.Value; } this.DbContext.SaveChanges(); return(this.Ok(response)); } }
public ActionResult Edit(RoleEditPostModel model) { //修改角色名称 roleService.Update(model.Id, model.Name); //修改权限项 permService.UpdatePermIds(model.Id, model.PermissionIds); return(Json(new AjaxResult() { Status = "ok" })); }
public ActionResult Edit(RoleEditPostModel model) { if (!ModelState.IsValid) { return(Json(new AjaxResult { Status = "error", ErrorMsg = MVCHelper.GetValidMsg(ModelState) })); } roleService.Update(model.Id, model.Name); perService.UpdatePermIds(model.Id, model.PermissionIds); return(Json(new AjaxResult { Status = "ok" })); }
public async Task <IActionResult> SaveEdit(RoleEditPostModel model) { var response = await HttpClientAsync.Async <HttpResponseModel>(RoleRoute.Edit, model); return(this.Submit(response)); }