コード例 #1
0
        public JsonResult GetNomeBebida(int id, short quantidade)
        {
            BebidaService bebidaService = new BebidaService();

            BebidaPedido bebida = new BebidaPedido() { NomeBebida = bebidaService.Find(id).Nome, Quantidade = quantidade };

            return Json(new { Result = bebida }, JsonRequestBehavior.AllowGet);
        }
コード例 #2
0
ファイル: PedidoService.cs プロジェクト: renanlessa/SextaNerd
        public IList<BebidaPedido> ListBebidasSugeridas()
        {
            IList<BebidaPedido> bebidas = new List<BebidaPedido>();
            BebidaPedido bebidaSuregida;

            using (Context db = new Context())
            {
                List<int?> listBebidas = (from p in db.Pedido
                                          where p.Atendido.Equals(0)
                                          where p.BebidaId != null
                                          select p.BebidaId).ToList();

                foreach (var idBebida in listBebidas.Distinct())
                {
                    bebidaSuregida = new BebidaPedido();
                    bebidaSuregida.NomeBebida = db.Bebida.Find(idBebida.Value).Nome;
                    bebidaSuregida.Quantidade = listBebidas.Count(x => x == idBebida);

                    bebidas.Add(bebidaSuregida);
                }
            }

            return bebidas;
        }