Esempio n. 1
0
 public LevantamentoIntegrationEventService(
     LevantamentoContext levantamentoContext,
     Func <DbConnection, IIntegrationEventLogService> integrationEventLogServiceFactory,
     IEventBus eventBus)
 {
     _levantamentoContext = levantamentoContext;
     _integrationEventLogServiceFactory = integrationEventLogServiceFactory ?? throw new ArgumentNullException(nameof(integrationEventLogServiceFactory));
     _eventLogService = _integrationEventLogServiceFactory(_levantamentoContext.Database.GetDbConnection());
     _eventBus        = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
 }
Esempio n. 2
0
        public static async Task DispatchDomainEventsAsync(this IMediator mediator, LevantamentoContext ctx)
        {
            var domainEntities = ctx.ChangeTracker
                                 .Entries <Entity>()
                                 .Where(x => x.Entity.DomainEvents != null && x.Entity.DomainEvents.Any());

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

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

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

            await Task.WhenAll(tasks);
        }
 public LevantamentoRepository(LevantamentoContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
Esempio n. 4
0
 public TransactionBehaviourNoSql(ILevantamentoIntegrationEventService levantamentoIntegrationEventService, LevantamentoContext context)
 {
     _levantamentoIntegrationEventService = levantamentoIntegrationEventService ?? throw new ArgumentException(nameof(levantamentoIntegrationEventService));
     _context = context ?? throw new ArgumentException(nameof(context));
 }
Esempio n. 5
0
 public UnitOfWork(LevantamentoContext context)
 {
     _context = context;
 }
Esempio n. 6
0
 public LevantamentoRepository(LevantamentoContext context)
 {
     _context = context;
     db       = _context.GetCollection <Domain.AggregatesModel.LevantamentoAggregate.Levantamentos>("Levantamento");
 }