public async Task<DeleteUserOutput> DeleteUser(DeleteUserInput input) { DeleteUserOutput result = await this._userBll.DeleteUser(input); return result; }
public async Task<DeleteUserOutput> DeleteUser(DeleteUserInput input) { DeleteUserOutput result = new DeleteUserOutput() { Status = 1 }; if (input.Ids != null && Enumerable.Count<int>((IEnumerable<int>)input.Ids) > 0) { bool success = false; foreach (int userId in input.Ids) { ApplicationUser user = await this.UserManager.FindByIdAsync(userId); if (user != null) { IdentityResult res = await this.UserManager.DeleteAsync(user); if (res.Succeeded) { foreach (Quang.Auth.Entities.Group group in this._userTable.GetGroupsByUser(user.Id)) this._userTable.removeUserFromGroup(group.Id, user.Id); foreach (KeyValuePair<Term, bool> keyValuePair in (IEnumerable<KeyValuePair<Term, bool>>)this._termTable.GetTermsByUser(user.Id)) this._termTable.removeTermFromUser(user.Id, keyValuePair.Key.Id); this._permissionTable.DeleteUserPermissions(user.Id); if (!success) success = res.Succeeded; } } } if (success) result.Status = 0; } return result; }