public async Task <User> UpdateAsync(User entity, string[] roles = null) { using (PasswordBoxUserManager manager = PasswordBoxUserManager.Create()) { var user = await manager.FindByIdAsync(entity.Id); user = user.Update(entity); var result = await manager.UpdateAsync(user); if (!result.Succeeded) { throw new BusinessException(result.Errors.Select(a => a.Description).ToList()); } await UpdateRolesAsync(entity.Id, roles, manager); } return(entity); }