public async Task SalvarEvento <TEvent>(TEvent evento) where TEvent : Event { await _eventStoreService.GetConnection().AppendToStreamAsync( evento.AggregateId.ToString(), ExpectedVersion.Any, FormatarEvento(evento)); }
public async Task <IEnumerable <StoredEvent> > ObterEventos(Guid aggregateId) { var eventos = await _eventStoreService.GetConnection() .ReadStreamEventsBackwardAsync(aggregateId.ToString(), 0, 500, false); var listaEventos = new List <StoredEvent>(); foreach (var resolveEvent in eventos.Events) { var dataEncoded = Encoding.UTF8.GetString(resolveEvent.Event.Data); var jsonData = JsonConvert.DeserializeObject <BaseEvent>(dataEncoded); var evento = new StoredEvent( resolveEvent.Event.EventId, resolveEvent.Event.EventType, jsonData.Timestamp, dataEncoded ); listaEventos.Add(evento); } return(listaEventos); }
public async Task PersistEvent <TEvent>(TEvent @event) where TEvent : Event { await _eventStoreService.GetConnection().AppendToStreamAsync( @event.AggregateId.ToString(), ExpectedVersion.Any, ToEventData(@event)); }
public async Task SaveEvent <TEvent>(TEvent @event) where TEvent : Event { try { await _eventStoreService.GetConnection().AppendToStreamAsync( @event.AggregateId.ToString(), ExpectedVersion.Any, FormatEvent(@event)); } catch (Exception ex) { } }