public async Task UpdateAsync(Account account, AccountUpdateRequest request) { AccountUpdateErrorFlags errorFlags = AccountUpdateErrorFlags.None; if (request.Password != null) { account.Password = _passwordHasher.HashPassword(account, request.Password); } if (request.Email != null && account.Email != request.Email) { if (await IsEmailInUse(request.Email)) { errorFlags |= AccountUpdateErrorFlags.EmailInUse; } else { account.Email = request.Email; } } if (errorFlags != AccountUpdateErrorFlags.None) { throw new AccountUpdateException( "An error occurred while updating the account.", errorFlags ); } await _accountContext.SaveChangesAsync(); }
public AccountUpdateException(string message, AccountUpdateErrorFlags errorFlags) : base(message) { ErrorFlags = errorFlags; }