Exemple #1
0
        public static async Task PublishEvents(this IMediator mediator, SalesContext ctx)
        {
            var domainEntities = ctx.ChangeTracker
                                 .Entries <Entity>()
                                 .Where(x => x.Entity.Notifications != null && x.Entity.Notifications.Any());

            var domainEvents = domainEntities
                               .SelectMany(x => x.Entity.Notifications)
                               .ToList();

            domainEntities.ToList()
            .ForEach(entity => entity.Entity.ClearEvents());

            var tasks = domainEvents
                        .Select(async(domainEvent) => {
                await mediator.Publish(domainEvent);
            });

            await Task.WhenAll(tasks);
        }
 public VendorRepository(SalesContext context)
 {
     salesContext = context ?? throw new ArgumentNullException(nameof(context));
 }
Exemple #3
0
 public SeedingService(SalesContext context)
 {
     _context = context;
 }