diff --git a/Workshops/IntroductionToEventSourcing/Solved/08-ApplicationLogic.Marten/Core/Marten/DocumentSessionExtensions.cs b/Workshops/IntroductionToEventSourcing/Solved/08-ApplicationLogic.Marten/Core/Marten/DocumentSessionExtensions.cs index d51da9ae2..3f60d825c 100644 --- a/Workshops/IntroductionToEventSourcing/Solved/08-ApplicationLogic.Marten/Core/Marten/DocumentSessionExtensions.cs +++ b/Workshops/IntroductionToEventSourcing/Solved/08-ApplicationLogic.Marten/Core/Marten/DocumentSessionExtensions.cs @@ -7,11 +7,8 @@ namespace ApplicationLogic.Marten.Core.Marten; public static class DocumentSessionExtensions { public static Task Add(this IDocumentSession documentSession, Guid id, object @event, CancellationToken ct) - where T : class - { - documentSession.Events.StartStream(id, @event); - return documentSession.SaveChangesAsync(token: ct); - } + where T : class => + documentSession.Add(id, [@event], ct); public static Task Add(this IDocumentSession documentSession, Guid id, object[] events, CancellationToken ct) where T : class @@ -35,10 +32,10 @@ CancellationToken ct Action handle, CancellationToken ct ) where T : class, IAggregate => - documentSession.Events.WriteToAggregate(id, stream => + documentSession.GetAndUpdate(id, state => { - var aggregate = stream.Aggregate ?? throw NotFoundException.For(id); - handle(aggregate); - stream.AppendMany(aggregate.DequeueUncommittedEvents()); + handle(state); + var events = state.DequeueUncommittedEvents(); + return events; }, ct); } diff --git a/Workshops/IntroductionToEventSourcing/Solved/09-ApplicationLogic.EventStoreDB/09-ApplicationLogic.EventStoreDB.csproj b/Workshops/IntroductionToEventSourcing/Solved/09-ApplicationLogic.EventStoreDB/09-ApplicationLogic.EventStoreDB.csproj index cdf38ea57..b156a83cb 100644 --- a/Workshops/IntroductionToEventSourcing/Solved/09-ApplicationLogic.EventStoreDB/09-ApplicationLogic.EventStoreDB.csproj +++ b/Workshops/IntroductionToEventSourcing/Solved/09-ApplicationLogic.EventStoreDB/09-ApplicationLogic.EventStoreDB.csproj @@ -9,10 +9,8 @@ - - - + diff --git a/Workshops/IntroductionToEventSourcing/Solved/09-ApplicationLogic.EventStoreDB/Program.cs b/Workshops/IntroductionToEventSourcing/Solved/09-ApplicationLogic.EventStoreDB/Program.cs index 94b2125bc..351e1cb2a 100644 --- a/Workshops/IntroductionToEventSourcing/Solved/09-ApplicationLogic.EventStoreDB/Program.cs +++ b/Workshops/IntroductionToEventSourcing/Solved/09-ApplicationLogic.EventStoreDB/Program.cs @@ -2,9 +2,7 @@ using ApplicationLogic.EventStoreDB.Immutable.ShoppingCarts; using ApplicationLogic.EventStoreDB.Mixed.ShoppingCarts; using ApplicationLogic.EventStoreDB.Mutable.ShoppingCarts; -using Marten; using Microsoft.AspNetCore.Diagnostics; -using Oakton; var builder = WebApplication.CreateBuilder(args);