Skip to content

Commit

Permalink
Fix - Correction de l'update d'un bankaccount
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmugnier committed Nov 25, 2020
1 parent 78add6b commit 30dd432
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
15 changes: 8 additions & 7 deletions Sheaft.Application.Handlers/Commands/PaymentCommandsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ public async Task<Result<bool>> Handle(UpdateBankAccountCommand request, Cancell
request.Address.Country)
: null;
bankAccount.SetAddress(address);
bankAccount.SetName(request.Name);
bankAccount.SetOwner(request.Owner);
bankAccount.SetIban(request.IBAN);
bankAccount.SetBic(request.BIC);
await _context.SaveChangesAsync(token);
if (!string.IsNullOrWhiteSpace(bankAccount.Identifier))
{
Expand All @@ -88,6 +81,14 @@ public async Task<Result<bool>> Handle(UpdateBankAccountCommand request, Cancell
bankAccount.SetIdentifier(string.Empty);
}
bankAccount.SetAddress(address);
bankAccount.SetName(request.Name);
bankAccount.SetOwner(request.Owner);
bankAccount.SetIban(request.IBAN);
bankAccount.SetBic(request.BIC);
await _context.SaveChangesAsync(token);
var result = await _pspService.CreateBankIbanAsync(bankAccount, token);
if (!result.Success)
return Failed<bool>(result.Exception);
Expand Down
6 changes: 4 additions & 2 deletions Sheaft.Exceptions/Enums/MessageKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ public enum MessageKind
Oidc_UpdateProfile_Error = 104004,
PsP_CannotCreate_Wallet_User_Not_Exists = 105001,
PsP_CannotCreate_Wallet_Wallet_Exists = 105002,
PsP_CannotCreate_Transfer_User_Not_Exists = 105003,
PsP_CannotCreate_Transfer_BankIBAN_Exists = 105004,
PsP_CannotCreate_Bank_User_Not_Exists = 105003,
PsP_CannotCreate_Bank_Already_Exists = 105004,
PsP_CannotCreate_Card_User_Not_Exists = 105005,
PsP_CannotCreate_Card_Card_Exists = 105006,
PsP_CannotValidate_Card_Card_Not_Exists = 105007,
Expand Down Expand Up @@ -262,5 +262,7 @@ public enum MessageKind
PsP_CannotUpdateUbo_Ubo_Not_Exists = 105039,
PsP_CannotCreate_User_User_Exists = 105040,
PsP_CannotUpdate_User_User_Not_Exists = 105041,
PsP_CannotUpdate_Bank_User_Not_Exists = 105042,
PsP_CannotUpdate_Bank_Not_Exists = 105043,
}
}
12 changes: 6 additions & 6 deletions Sheaft.Infrastructure.Services/PspService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ public async Task<Result<string>> CreateBankIbanAsync(BankAccount payment, Cance
return await ExecuteAsync(async () =>
{
if (string.IsNullOrWhiteSpace(payment.User.Identifier))
return BadRequest<string>(MessageKind.PsP_CannotCreate_Transfer_User_Not_Exists);
return BadRequest<string>(MessageKind.PsP_CannotCreate_Bank_User_Not_Exists);
if (!string.IsNullOrWhiteSpace(payment.Identifier))
return BadRequest<string>(MessageKind.PsP_CannotCreate_Transfer_BankIBAN_Exists);
if (payment.Identifier.Length > 0)
return BadRequest<string>(MessageKind.PsP_CannotCreate_Bank_Already_Exists);
await EnsureAccessTokenIsValidAsync(token);
Expand Down Expand Up @@ -215,10 +215,10 @@ public async Task<Result<bool>> UpdateBankIbanAsync(BankAccount payment, bool is
return await ExecuteAsync(async () =>
{
if (string.IsNullOrWhiteSpace(payment.User.Identifier))
return BadRequest<bool>(MessageKind.PsP_CannotCreate_Transfer_User_Not_Exists);
return BadRequest<bool>(MessageKind.PsP_CannotUpdate_Bank_User_Not_Exists);
if (!string.IsNullOrWhiteSpace(payment.Identifier))
return BadRequest<bool>(MessageKind.PsP_CannotCreate_Transfer_BankIBAN_Exists);
if (string.IsNullOrWhiteSpace(payment.Identifier))
return BadRequest<bool>(MessageKind.PsP_CannotUpdate_Bank_Not_Exists);
await EnsureAccessTokenIsValidAsync(token);
Expand Down

0 comments on commit 30dd432

Please sign in to comment.