Working at last!
This commit is contained in:
@@ -10,10 +10,10 @@ public static class ApplyFeeHandler
|
|||||||
{
|
{
|
||||||
public static Task<Account?> LoadAsync(
|
public static Task<Account?> LoadAsync(
|
||||||
ApplyFeeCommand cmd,
|
ApplyFeeCommand cmd,
|
||||||
AccountDbContext db) => db.Set<Account>().AsNoTracking().SingleOrDefaultAsync(x => x.Id == cmd.AccountId);
|
AccountDbContext db) => db.Accounts.AsNoTracking().SingleOrDefaultAsync(x => x.Id == cmd.AccountId);
|
||||||
|
|
||||||
[Transactional]
|
[Transactional]
|
||||||
public static (Update<Account> UpdatedAccount, FeeAppliedEvent Event) Handle(
|
public static (IStorageAction<Account> UpdatedAccount, FeeAppliedEvent Event) Handle(
|
||||||
ApplyFeeCommand cmd,
|
ApplyFeeCommand cmd,
|
||||||
Account account)
|
Account account)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using FinancialApi;
|
|||||||
using FinancialApi.Infrastructure;
|
using FinancialApi.Infrastructure;
|
||||||
using FinancialApi.ServiceDefaults;
|
using FinancialApi.ServiceDefaults;
|
||||||
using JasperFx.CodeGeneration;
|
using JasperFx.CodeGeneration;
|
||||||
|
using JasperFx.Resources;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Wolverine;
|
using Wolverine;
|
||||||
using Wolverine.EntityFrameworkCore;
|
using Wolverine.EntityFrameworkCore;
|
||||||
@@ -10,8 +11,10 @@ using Wolverine.Sqlite;
|
|||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
var connectionString = "Data Source=demo.db";
|
||||||
|
|
||||||
builder.Services.AddDbContext<AccountDbContext>(options =>
|
builder.Services.AddDbContext<AccountDbContext>(options =>
|
||||||
options.UseSqlite("Data Source=demo.db"));
|
options.UseSqlite(connectionString));
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||||
@@ -21,9 +24,12 @@ builder.AddServiceDefaults();
|
|||||||
|
|
||||||
builder.Host.UseWolverine(opts =>
|
builder.Host.UseWolverine(opts =>
|
||||||
{
|
{
|
||||||
opts.PersistMessagesWithSqlite("Data Source=demo.db");
|
opts.Discovery.IncludeAssembly(typeof(ApplyFeeHandler).Assembly);
|
||||||
|
opts.PersistMessagesWithSqlite(connectionString);
|
||||||
opts.UseEntityFrameworkCoreTransactions();
|
opts.UseEntityFrameworkCoreTransactions();
|
||||||
|
opts.Policies.AutoApplyTransactions();
|
||||||
});
|
});
|
||||||
|
builder.Host.UseResourceSetupOnStartup();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user