示例#1
0
        public async Task <bool> Handle(DeleteStatementCommand request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (!request.IsValid())
            {
                await _mediatorHandler.RaiseEvent(
                    new DomainValidationEvent(request.ValidationResult.ToString()));

                return(false);
            }

            var oldStatement = _statementRepository.GetById(request.Id);

            if (oldStatement == null)
            {
                await _mediatorHandler.RaiseEvent(new NotFoundEvent(request.Id, "Statement", "Statement not found."));

                return(false);
            }

            _statementRepository.Delete(request.Id);

            await _mediatorHandler.RaiseEvent(new StatementDeletedEvent()
            {
                Old = oldStatement
            });

            return(true);
        }
 public ResultMessage <Statement> Delete(int id)
 {
     return(statementRepository.Delete(id));
 }