public async Task DeveRetornarErroAoConsultarGarcomPorIdComIdsIncorretos(Guid id) { var handler = new GarcomQueryHandler(_garcomDapper, _mediator, _garcomRepository); var command = new ObterGarcomQuery(id); await handler.Handle(command, new CancellationToken()); Assert.True(command.Invalid); }
public async Task <GarcomDto> Handle(ObterGarcomQuery request, CancellationToken cancellationToken) { if (request.Id == null || request.Id == Guid.Empty) { request.AddNotification("ObterCarcomQuery.Id", "Id é obrigatório."); } if (request.Invalid) { await _mediator.Publish(new DomainNotification { Erros = request.Notifications }, cancellationToken); GarcomDto clienteNull = null; return(await Task.FromResult(clienteNull)); } return(_garcomRepository.GetById(request.Id)); }
public async Task <GarcomDto> Obter(Guid id) { var command = new ObterGarcomQuery(id); return(await _mediator.Send(command)); }