Example #1
0
        public async Task SaveEventAsync <T>(T @event, int aggregateVersion, DateTime requestedTime, string requestedBy)
        {
            var simpleApplicationEvent = SimpleApplicationEvent.New(@event, aggregateVersion, requestedTime, requestedBy);
            await ApplicationEvents.AddAsync(simpleApplicationEvent);

            await SaveChangesAsync();
        }
Example #2
0
        // We initialize this in a startup.cs instead of here.
        //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        //{
        //    optionsBuilder.UseSqlite("DataSource=:memory:");
        //}

        public async Task SavePendingEventsAsync(Queue <ISimpleEvent> pendingEvents, int aggregateVersion, string requestedBy)
        {
            var applicationEvents = pendingEvents.Select(e => SimpleApplicationEvent.New(e, aggregateVersion, DateTime.UtcNow, requestedBy));
            await ApplicationEvents.AddRangeAsync(applicationEvents);

            await SaveChangesAsync();
        }