public Task Handle(UpdateCategoryCommand request, CancellationToken cancellationToken) { var categoryCurrent = _categoryRepository.GetById(request.Id); if (categoryCurrent == null) { _mediator.Publish(new DomainNotification(request.MessageType, "Category not found.")); return(Task.FromResult(Unit.Value)); } var category = Category.CategoryFactory.NewCategoryFull(request.Id, request.Name); if (!CategoryValid(category)) { return(Task.CompletedTask); } _categoryRepository.UpDate(category); if (Commit()) { //Event Sourcing //Event after update category. } return(Task.CompletedTask); }
protected void NotificarValidacoesErro(ValidationResult validationResult) { foreach (var error in validationResult.Errors) { _mediator.Publish(new DomainNotification(error.PropertyName, error.ErrorMessage)); } }
protected void RaiseEvents(IReadOnlyList <INotification> events) { foreach (var @event in events) { _mediator.Publish(@event); } }
public Task Handle(RemoveProductCommand request, CancellationToken cancellationToken) { var productCurrent = _productRepository.GetById(request.Id); if (productCurrent == null) { _mediator.Publish(new DomainNotification(request.MessageType, "Product not found.")); return(Task.CompletedTask); } _productRepository.Remove(request.Id); if (Commit()) { //Event Sourcing //Event after update product. } return(Task.CompletedTask); }
protected void ReportError(string codigo, string mensagem) { _mediator.Publish(new DomainNotification(codigo, mensagem)); }