public async Task UpdateAsync(Product entity, CancellationToken ct) { await _productRepository.UpdateAsync(entity, ct); await SaveChangesAsync(ct); await _eventStoreService.Save(entity); }
public async Task Publish <T>(T @event) where T : Event { if ([email protected](nameof(DomainNotification))) { await _eventStore.Save(@event); } await _mediator.Publish(@event); }
public Task RaiseEvent <T>(T @event) where T : Event { if ([email protected]("DomainNotification")) { _eventStore?.Save(@event); } return(_mediator.Publish(@event)); }
/// <summary> /// 引发事件的实现方法 /// </summary> /// <typeparam name="T">泛型 继承 Event:INotification</typeparam> /// <param name="event">事件模型,比如StudentRegisteredEvent</param> /// <returns></returns> public Task RaiseEvent <T>(T @event) where T : Event { //除了领域通知以外 的事件都保存下来 if ([email protected]("DomainNotification")) { _eventStoreService?.Save(@event); //MediatR中介者模式中的第二种方法,发布 / 订阅模式 } return(_mediator.Publish(@event)); }
/// <summary> /// 发布事件通知 /// </summary> /// <typeparam name="TNotification"></typeparam> /// <param name="event">通知事件</param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task PublishEvent <TNotification>(TNotification @event, CancellationToken cancellationToken = default(CancellationToken)) where TNotification : Event { // 除了领域通知以外的事件都保存下来 if ([email protected]("DomainNotification")) { eventStoreService?.Save(@event); } // MediatR中介者模式中的第二种方法,发布/订阅模式 return(mediator.Publish(@event)); }
public async Task ManageEvent(IAggregateInfo aggregateInfo, int eventVersion, IEvent e) { var dto = EventStoreMapper.EventMapper(aggregateInfo, eventVersion, e); try { await _service.Save(dto); } catch (Exception ex) { throw ex; } }
public async Task ManageEvent(IAggregateInfo aggregateInfo, int eventVersion, IEvent e) { var dto = EventStoreMapper.EventMapper(aggregateInfo, eventVersion, e); try { await _service.Save(dto); _presenter.PublishAmountDeposited(dto.AggregateId, dto.AggregateData); } catch (Exception ex) { throw ex; } }
public async Task ManageEvent(IAggregateInfo aggregateInfo, int eventVersion, IEvent e) { var dto = EventStoreMapper.EventMapper(aggregateInfo, eventVersion, e); try { await _service.Save(dto); _presenter.PublishAccountCreated(dto.AggregateId, dto.AggregateData); } catch (Exception ex) { _presenter.PublishErrorCreatingAccount(ex.Message); throw; } }
/// <summary> /// 发布事件 /// </summary> /// <param name="eventEntity"></param> public void Publish(AbstractEvent eventEntity) { IList <IEventObserver> eventObservers = eventObserverProvider.GetEventObservers(); foreach (IEventObserver eventObserver in eventObservers) { if (eventObserver.Support(eventEntity.GetType())) { try { eventObserver.Receive(eventEntity); } catch (Exception ex) { eventStoreService.Save(eventEntity, ex); } } } }
public async Task Save(EventStoredDTO e) { await _service.Save(e); }
public async Task <ActionResult> Create([FromBody] CreateEventStoreDto createEventStoreDto) { return(Ok(await _evenStoreService.Save(createEventStoreDto))); }
public Task <R> SendCommand <T, R>(T command) where T : Command <R> { //存储所有的领域命令 Task.Run(() => _eventStoreService.Save(command)); return(_mediator.Send(command)); }