Task IEventHandler <TripCreated> .HandleAsync(TripCreated @event, CancellationToken cancellationToken) { _cache.Set( GetCacheKey(@event.CorrelationId), @event.TripId, CacheExpiration); return(Task.CompletedTask); }
// Applies events after load an object from event store. (kinda memento pattern) private void Apply(TripCreated @event) { Id = @event.AggregateRootId; _driverId = @event.DriverId; _from = @event.From; _to = @event.To; _userId = @event.UserTripId; _vehicleInformation = @event.VehicleInformation; }