Added all projects
We are almost working.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using FinancialApi.Application;
|
||||
using FinancialApi.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FinancialApi;
|
||||
|
||||
public static class ApplyFeeHandler
|
||||
{
|
||||
public static Task<Account?> LoadAsync(ApplyFeeCommand cmd, AccountDbContext db)
|
||||
=> db.Set<Account>().AsNoTracking()
|
||||
.FirstOrDefaultAsync(x => x.Id == cmd.AccountId);
|
||||
|
||||
public static (Account UpdatedAccount, FeeAppliedEvent Event) Handle(ApplyFeeCommand cmd, Account account)
|
||||
{
|
||||
var updatedAccount = account.ApplyFee(cmd.Amount);
|
||||
|
||||
var @event = new FeeAppliedEvent(account.Id, cmd.Amount);
|
||||
|
||||
return (updatedAccount, @event);
|
||||
}
|
||||
}
|
||||
|
||||
public record ApplyFeeCommand(int AccountId, decimal Amount);
|
||||
|
||||
public record FeeAppliedEvent(int AccountId, decimal Amount);
|
||||
Reference in New Issue
Block a user