Ejemplo n.º 1
0
        public async Task DeveRetornarErroAoConsultarComandaPorIdComIdsIncorretos(Guid id)
        {
            var handler = new ComandaQueryHandler(_comandaDapper, _mediator, _comandaRepository);
            var command = new ObterComandaQuery(id);

            await handler.Handle(command, new CancellationToken());

            Assert.True(command.Invalid);
        }
        public async Task <ComandaDto> Handle(ObterComandaQuery request, CancellationToken cancellationToken)
        {
            if (request.Id == null || request.Id == Guid.Empty)
            {
                request.AddNotification("ObterComandaQuery.Id", "Id é obrigatório.");
            }

            if (request.Invalid)
            {
                await _mediator.Publish(new DomainNotification
                {
                    Erros = request.Notifications
                }, cancellationToken);

                ComandaDto comandaNull = null;

                return(await Task.FromResult(comandaNull));
            }

            return(_comandaRepository.GetById(request.Id));
        }
Ejemplo n.º 3
0
        public async Task <ComandaDto> Obter(Guid id)
        {
            var command = new ObterComandaQuery(id);

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