Reformat all code as per my preferred formatting.
This commit is contained in:
@@ -19,8 +19,7 @@ builder.Services.AddProblemDetails();
|
||||
|
||||
var connectionString = "Data Source=demo.db";
|
||||
|
||||
builder.Services.AddDbContext<AccountDbContext>(options =>
|
||||
options.UseSqlite(connectionString));
|
||||
builder.Services.AddDbContext<AccountDbContext>(options => options.UseSqlite(connectionString));
|
||||
|
||||
builder.Services.AddScoped<IAccountQuery, AccountQuery>();
|
||||
builder.Services.AddScoped<IReversalQuery, ReversalQuery>();
|
||||
@@ -33,13 +32,14 @@ builder.Services.AddOpenApi();
|
||||
builder.AddServiceDefaults();
|
||||
|
||||
builder.Host.UseWolverine(opts =>
|
||||
{
|
||||
opts.Discovery.IncludeAssembly(typeof(DemoEventStore).Assembly);
|
||||
opts.Discovery.IncludeAssembly(typeof(ApplyFeeHandler).Assembly);
|
||||
opts.PersistMessagesWithSqlite(connectionString);
|
||||
opts.UseEntityFrameworkCoreTransactions();
|
||||
opts.Policies.AutoApplyTransactions();
|
||||
});
|
||||
{
|
||||
opts.Discovery.IncludeAssembly(typeof(DemoEventStore).Assembly);
|
||||
opts.Discovery.IncludeAssembly(typeof(ApplyFeeHandler).Assembly);
|
||||
opts.PersistMessagesWithSqlite(connectionString);
|
||||
opts.UseEntityFrameworkCoreTransactions();
|
||||
opts.Policies.AutoApplyTransactions();
|
||||
}
|
||||
);
|
||||
builder.Host.UseResourceSetupOnStartup();
|
||||
|
||||
var app = builder.Build();
|
||||
@@ -60,32 +60,44 @@ if (app.Environment.IsDevelopment())
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.MapPost("/accounts/apply-fee", async (ApplyFeeCommand cmd, IMessageBus bus) =>
|
||||
{
|
||||
await bus.InvokeAsync(cmd);
|
||||
return Results.Accepted();
|
||||
});
|
||||
|
||||
app.MapPost("/accounts/transfer", async (TransferFundsCommand cmd, IMessageBus bus) =>
|
||||
{
|
||||
await bus.InvokeAsync(cmd);
|
||||
return Results.Accepted();
|
||||
});
|
||||
|
||||
app.MapPost("/journal/reverse", async (ReverseJournalCommand cmd, IMessageBus bus) =>
|
||||
{
|
||||
await bus.InvokeAsync(cmd);
|
||||
return Results.Accepted();
|
||||
});
|
||||
|
||||
app.MapGet("/events", (IEventTracker tracker) =>
|
||||
{
|
||||
if (tracker is DemoEventStore store)
|
||||
app.MapPost(
|
||||
"/accounts/apply-fee",
|
||||
async (ApplyFeeCommand cmd, IMessageBus bus) =>
|
||||
{
|
||||
return Results.Ok(store.CapturedEvents);
|
||||
await bus.InvokeAsync(cmd);
|
||||
return Results.Accepted();
|
||||
}
|
||||
);
|
||||
|
||||
return Results.NotFound();
|
||||
});
|
||||
app.MapPost(
|
||||
"/accounts/transfer",
|
||||
async (TransferFundsCommand cmd, IMessageBus bus) =>
|
||||
{
|
||||
await bus.InvokeAsync(cmd);
|
||||
return Results.Accepted();
|
||||
}
|
||||
);
|
||||
|
||||
app.MapPost(
|
||||
"/journal/reverse",
|
||||
async (ReverseJournalCommand cmd, IMessageBus bus) =>
|
||||
{
|
||||
await bus.InvokeAsync(cmd);
|
||||
return Results.Accepted();
|
||||
}
|
||||
);
|
||||
|
||||
app.MapGet(
|
||||
"/events",
|
||||
(IEventTracker tracker) =>
|
||||
{
|
||||
if (tracker is DemoEventStore store)
|
||||
{
|
||||
return Results.Ok(store.CapturedEvents);
|
||||
}
|
||||
|
||||
return Results.NotFound();
|
||||
}
|
||||
);
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user