public async Task <IActionResult> UserRemoveRoles([FromBody] UserRemoveRolesInputDto input) { var userRoleService = this._remoteServiceClient.CreateUserRoleAppService(); var success = await userRoleService.DeleteUsersRoleAsync(input.UserId, input.RoleIds); return(Json(success, null, success ? "操作成功" : "操作失败")); }
/// <summary> /// 用户更新多个角色 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <IActionResult> OnPostUpdateUserRoles([FromBody] UserRemoveRolesInputDto input) { //1.先删除 var roles = await this._userRoleService.FindRolesByUserIdAsync(input.UserId); await this._userRoleService.DeleteUsersRoleAsync(input.UserId, roles.Select(u => u.ID).ToList()); var success = await this._userRoleService.CreateUsersRoleAsync(input.UserId, input.RoleIds); return(new JsonResult(new { success = success, message = success ? "操作成功" : "操作失败" })); }
public async Task <IActionResult> UpdateUserRoles([FromBody] UserRemoveRolesInputDto input) { var userRoleService = this._remoteServiceClient.CreateUserRoleAppService(); //1.先删除 var roles = await userRoleService.FindRolesByUserIdAsync(input.UserId); await userRoleService.DeleteUsersRoleAsync(input.UserId, roles.Select(u => u.ID).ToList()); var success = await userRoleService.CreateUsersRoleAsync(input.UserId, input.RoleIds); return(Json(success, null, success ? "操作成功" : "操作失败")); }
/// <summary> /// 用户移除一个或者多个角色 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <IActionResult> OnPostUserRemoveRoles([FromBody] UserRemoveRolesInputDto input) { var success = await this._userRoleService.DeleteUsersRoleAsync(input.UserId, input.RoleIds); return(new JsonResult(new { success = success, message = success ? "操作成功" : "操作失败" })); }