Beispiel #1
0
        public async Task <ValidationResult> Handle(PedidoItemDeletarCommand comando, CancellationToken cancelar)
        {
            if (comando.EhValido())
            {
                await _pedidoRepository.RemoverItemAsync(comando.Id);

                if (!await _unitOfWork.SalvarAsync())
                {
                    comando.Validacao.Errors.Add(new ValidationFailure("Salvar", "Erro ao tentar salvar operação"));
                }
            }

            return(comando.Validacao);
        }
        public async Task <ValidationResult> DeletarItem(Guid id, Guid pedidoItemId)
        {
            PedidoItemDeletarCommand pedidoItemDeletarCommand = new PedidoItemDeletarCommand(pedidoItemId, id);

            return(await _mediator.Send(pedidoItemDeletarCommand));
        }