Created
October 25, 2012 14:44
-
-
Save andlju/3952974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just nu ser mina Command Handlers ut så här: | |
public class CreateBookingCommandHandler : IHandleMessages<CreateBooking> | |
{ | |
private readonly IRepository _repository; | |
public CreateBookingCommandHandler(IRepository repository) | |
{ | |
_repository = repository; | |
} | |
public void Handle(CreateBooking command) | |
{ | |
var booking = new Domain.Booking(command.BookingId, (Tcne.Booking.Domain.BookingStatus)command.Status); | |
// Sparar till Repository efter varje Command | |
_repository.Save(booking, Guid.NewGuid() , null); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Jag vill istället låta NServiceBus sköta Save-hanteringen. Typ: | |
public class EventStoreUnitOfWork : IManageUnitsOfWork | |
{ | |
private readonly IRepository _repository; | |
public EventStoreUnitOfWork(IRepository repository) | |
{ | |
_repository = repository; | |
} | |
public void Begin() | |
{ | |
} | |
public void End(Exception ex = null) | |
{ | |
// Men.. här har jag ju inte koll på vilken/vilka Aggregates jag har jobbat med | |
if (ex == null) | |
_repository.Save(?, ?, ?); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment