示例#1
0
        public async Task <Comanda> AlterarSituacaoPedido(int comandaId, ComandaPedidoSituacao situacao)
        {
            var pedidos = await _dbSetComandaPedido
                          .Where(c => c.Comanda.Id == comandaId && c.Situacao != ComandaPedidoSituacao.Cancelado)
                          .ToListAsync();

            foreach (var pedido in pedidos)
            {
                pedido.Situacao = situacao;
                _dbContext.Update(pedido);
            }

            await Commit();

            return(await _dbSet.Where(c => c.Id == comandaId)
                   .Include(c => c.Garcom)
                   .Include(c => c.Pedidos)
                   .ThenInclude(c => c.Produto)
                   .FirstOrDefaultAsync());
        }
示例#2
0
        public async Task <IActionResult> AlterarSituacaoPedido([FromRoute] int comandaId, [FromBody] ComandaPedidoSituacao situacao)
        {
            try
            {
                var result = await _appService.AlterarSituacaoPedido(comandaId, situacao);

                if (situacao == ComandaPedidoSituacao.Pronto)
                {
                    await SendMessage($"Pedidos comanda {comandaId} estão prontos!");
                }

                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(Error(ex));
            }
        }
示例#3
0
 public async Task <Comanda> AlterarSituacaoPedido(int comandaId, ComandaPedidoSituacao situacao)
 {
     return(await _repository.AlterarSituacaoPedido(comandaId, situacao));
 }