public void Handle(SessionDeleted @event) { using (var context = new ProjectionContext(ConnectionString.Get())) { var entity = new SessionSqlEntity() { SessionId = @event.AggregateId }; context.Sessions.Attach(entity); context.Sessions.Remove(entity); context.SaveChanges(); } }
public void Handle(SessionPlanned @event) { using (var context = new ProjectionContext(ConnectionString.Get())) { var entity = context.Sessions.Find(@event.AggregateId); if (entity == null) { entity = new SessionSqlEntity(); context.Sessions.Add(entity); } entity.TrainingId = @event.TrainingId; entity.SessionId = @event.AggregateId; entity.SessionStart = @event.SessionStart; entity.Duration = @event.Duration; entity.TrainerId = @event.TrainerId; entity.LocationId = @event.LocationId; entity.Seats = @event.Seats; entity.ReservedSeats = 0; context.SaveChanges(); } }