First attempts to get wolverine a-frame going!
This commit is contained in:
@@ -1,22 +1,28 @@
|
||||
using FinancialApi.Application;
|
||||
using FinancialApi.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Wolverine.Attributes;
|
||||
using Wolverine.Persistence;
|
||||
|
||||
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 Task<Account?> LoadAsync(
|
||||
ApplyFeeCommand cmd,
|
||||
AccountDbContext db) => db.Set<Account>().AsNoTracking().SingleOrDefaultAsync(x => x.Id == cmd.AccountId);
|
||||
|
||||
public static (Account UpdatedAccount, FeeAppliedEvent Event) Handle(ApplyFeeCommand cmd, Account account)
|
||||
[Transactional]
|
||||
public static (Update<Account> UpdatedAccount, FeeAppliedEvent Event) Handle(
|
||||
ApplyFeeCommand cmd,
|
||||
Account account,
|
||||
AccountDbContext db)
|
||||
{
|
||||
var updatedAccount = account.ApplyFee(cmd.Amount);
|
||||
|
||||
var @event = new FeeAppliedEvent(account.Id, cmd.Amount);
|
||||
|
||||
return (updatedAccount, @event);
|
||||
return (Storage.Update(updatedAccount), @event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user