Beispiel #1
0
        public async Task SaveEventAsync(IntegrationEvent integrationEvent)
        {
            Guard.Requires(integrationEvent, nameof(integrationEvent)).IsNotNull();

            if (await repository.CheckIfExistsByEventIdAsync(integrationEvent.EventId))
            {
                throw new Exception($"Internal error - event id: {integrationEvent.EventId} exists in event log");
            }

            await repository.CreateAsync(
                new IntegrationEventLog
            {
                State             = IntegrationEventState.ReadyToPublish,
                EventId           = integrationEvent.EventId,
                EventCreationDate = integrationEvent.EventCreationDate,
                EventType         = integrationEvent.GetType().FullName,
                EventBody         = JsonConvert.SerializeObject(integrationEvent)
            }
                );
        }