public async Task DeveRetornarErroAoConsultarClintePorIdComIdsIncorretos(Guid id) { var handler = new PedidoQueryHandler(_pedidoDapper, _mediator, _pedidoRepository); var command = new ObterPedidoQuery(id); await handler.Handle(command, new CancellationToken()); Assert.True(command.Invalid); }
public async Task <PedidoDto> Handle(ObterPedidoQuery request, CancellationToken cancellationToken) { if (request.Id == null || request.Id == Guid.Empty) { request.AddNotification("ObterPedidoQuery.Id", "Id é obrigatório."); } if (request.Invalid) { await _mediator.Publish(new DomainNotification { Erros = request.Notifications }, cancellationToken); PedidoDto clienteNull = null; return(await Task.FromResult(clienteNull)); } return(_pedidoRepository.GetById(request.Id)); }
public async Task <PedidoDto> Obter(Guid id) { var command = new ObterPedidoQuery(id); return(await _mediator.Send(command)); }
public async Task <ObterPedidoResult> Handle(ObterPedidoQuery request, CancellationToken cancellationToken) { var result = await _repository.ObterPorId(request.IdPedido); return(_mapper.Map <ObterPedidoResult>(result)); }