Exemple #1
0
        public async Task <ICommandResult> Handle(RemoveOrdemServicoCommand command)
        {
            try
            {
                await _ordemServicoRepository.RemoveAsync(command.Id);

                await _uow.CommitAsync();

                return(new CommandResult(true, "Ordem de servico excluída com sucesso", null));
            }
            catch (Exception e)
            {
                await _uow.RollbackAsync();

                return(new CommandResult(false, $"Problema com a exclusão, tente mais tarde. Erro ${e.Message}", null));
            }
        }
Exemple #2
0
        public Task <CommandResult> Handle(RemoveOrdemServicoCommand command, CancellationToken cancellationToken)
        {
            if (!command.IsValid())
            {
                NotifyCommandErrors(command);
                return(Response());
            }

            OrdemServico ordemServico = _ordemServicoRepository.GetById(command.Id);

            _ordemServicoRepository.Remove(ordemServico);

            if (Commit())
            {
                _mediator.Publish(new RemovedOrdemServicoEvent());
            }

            return(Response());
        }
        public async Task <ValidationResult> Remove(Guid id)
        {
            var removeCommand = new RemoveOrdemServicoCommand(id);

            return(await _mediator.SendCommand(removeCommand));
        }