public static async Task DispatchDomainEvent(this IMediator mediator, CurriculumContext ctx)
        {
            var domianEntities = ctx.ChangeTracker.Entries <Entity>().Where(v => v.Entity.DomainEventList != null && v.Entity.DomainEventList.Any());

            var domianEvents = domianEntities.SelectMany(v => v.Entity.DomainEventList).ToList();

            domianEntities.ToList().ForEach(v => v.Entity.Clear());

            var tasks = domianEvents.Select((async(domainevent) => await mediator.Publish(domainevent)));

            await Task.WhenAll(tasks);
        }
Exemplo n.º 2
0
 public CurriculumRepository(CurriculumContext _context)
 {
     context = _context;
 }