Skip to content

Commit ad78e24

Browse files
Add UpdateBankAccount command and enhance error handling
Introduced `UpdateBankAccountCommand` and its handler for future updates to bank accounts. Enhanced error handling in `CreateBankAccount` endpoint to return proper error responses. Removed unused fields from `CreateBankAccountCommand` and updated the project structure.
1 parent 250e8b8 commit ad78e24

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

Controllers/BankAccountController.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ public BankAccountController(IMediator mediator)
1818
[HttpPost("create-bank-account")]
1919
public async Task<IActionResult> Create([FromBody] CreateBankAccountCommand command)
2020
{
21-
var bankAccount = await _mediator.Send(command);
22-
return SuccessResponse(bankAccount);
21+
try
22+
{
23+
var bankAccount = await _mediator.Send(command);
24+
return SuccessResponse(bankAccount);
25+
}
26+
catch (Exception ex)
27+
{
28+
return ErrorResponse(ex.Message, 400);
29+
}
2330
}
31+
2432
}

Features/BankAccounts/Commands/CreateBankAccountCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ public class CreateBankAccountCommand : IRequest<BankAccount>
77
{
88
[Required]
99
public string? AccountNumber { get; set; }
10-
public string? Currency { get; set; }
11-
public decimal Balance { get; set; }
1210
[Required]
1311
[StringLength(6, MinimumLength = 6)]
1412
public string CodePinHash { get; set; }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace PaymentCoreServiceApi.Features.BankAccounts.Commands;
2+
3+
public class UpdateBankAccountCommand
4+
{
5+
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace PaymentCoreServiceApi.Features.BankAccounts.Commands;
2+
3+
public class UpdateBankAccountCommandHandler
4+
{
5+
6+
}

PaymentCoreServiceApi.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
</ItemGroup>
2525

2626
<ItemGroup>
27+
<Folder Include="Common\DTOs\" />
2728
<Folder Include="Core\Caches\" />
2829
<Folder Include="Features\BankAccounts\Queries\" />
2930
</ItemGroup>

0 commit comments

Comments
 (0)