First attempts to get wolverine a-frame going!

This commit is contained in:
2026-07-14 16:06:36 +02:00
parent bf16b7b807
commit 04025d12b4
@@ -1,22 +1,28 @@
using FinancialApi.Application; using FinancialApi.Application;
using FinancialApi.Infrastructure; using FinancialApi.Infrastructure;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Wolverine.Attributes;
using Wolverine.Persistence;
namespace FinancialApi; namespace FinancialApi;
public static class ApplyFeeHandler public static class ApplyFeeHandler
{ {
public static Task<Account?> LoadAsync(ApplyFeeCommand cmd, AccountDbContext db) public static Task<Account?> LoadAsync(
=> db.Set<Account>().AsNoTracking() ApplyFeeCommand cmd,
.FirstOrDefaultAsync(x => x.Id == cmd.AccountId); 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 updatedAccount = account.ApplyFee(cmd.Amount);
var @event = new FeeAppliedEvent(account.Id, cmd.Amount); var @event = new FeeAppliedEvent(account.Id, cmd.Amount);
return (updatedAccount, @event); return (Storage.Update(updatedAccount), @event);
} }
} }