public async Task <ValidationResult> Handle(RemoveOrdemServicoExameCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                return(request.ValidationResult);
            }

            var OrdemServicoExame = await _OrdemServicoExameRepository.GetById(request.Id);

            if (OrdemServicoExame is null)
            {
                AddError("Item não existe");
                return(ValidationResult);
            }

            OrdemServicoExame.AddDomainEvent(new OrdemServicoExameRemovedEvent(request.Id));

            _OrdemServicoExameRepository.Remove(OrdemServicoExame);

            return(await Commit(_OrdemServicoExameRepository.UnitOfWork));
        }
Ejemplo n.º 2
0
 public async Task <OrdemServicoExameViewModel> GetById(Guid id) =>
 _mapper.Map <OrdemServicoExameViewModel>(await _ordemServicoExameRepository.GetById(id));