public async Task SaveAsync <T>(T @event) where T : Event { var loggedEvent = new LoggedEvent() { Action = @event.Name, AggregateId = @event.AggregateId, Data = JsonSerializer.Serialize(@event, @event.GetType()) }; try { await _eventRepository.SaveAsync(loggedEvent); } catch (Exception e) { _logger.LogError(e, "Error while trying to save logged event."); } }
public async Task SaveAsync(LoggedEvent @event) { @event.TimeStamp = DateTime.UtcNow; _dbContext.LoggedEvents.Add(@event); await _dbContext.SaveChangesAsync(); }