コード例 #1
0
        public ActionResult Carro(PEDIDO_PLATOS collection, string idMesa)
        {
            try
            {
                int    idCliente = Convert.ToInt32(Session["idcliente"]);;
                PEDIDO ped       = new PEDIDO();
                ped.CLIENTE_ID_CLIENTE = idCliente;
                ped.ESTADO_PEDIDO      = 0;
                ped.FECHA_PEDIDO       = DateTime.Now;
                ped.MESA_NUM_MESA      = Convert.ToInt32(idMesa);
                context.insertarPedido(ped);
                List <PEDIDO_PLATOS> platos = CarroDeCompras.CapturarProducto().ListaProductos;

                foreach (var item in platos)
                {
                    item.PEDIDO_ID_PEDIDO = context.buscarIdPedido(idCliente);
                    this.context.insertarPedidoPlatos(item);
                }
                System.Web.HttpContext.Current.Session.Remove("ASPCarroDeCompras");
                return(RedirectToAction("index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #2
0
        public void Agregar(int pIdProducto)
        {
            PEDIDO_PLATOS NuevoProducto = new PEDIDO_PLATOS();

            using (EntitiesRestaurante entities = new EntitiesRestaurante())
            {
                NuevoProducto.PLATO          = entities.PLATO.Where(n => n.ID_PLATO == pIdProducto).FirstOrDefault();
                NuevoProducto.PLATO_ID_PLATO = NuevoProducto.PLATO.ID_PLATO;
            }
            if (ListaProductos.Where(n => n.PLATO_ID_PLATO == NuevoProducto.PLATO_ID_PLATO).FirstOrDefault() != null)
            {
                foreach (PEDIDO_PLATOS item in ListaProductos)
                {
                    if (item.PLATO_ID_PLATO.Equals(NuevoProducto.PLATO_ID_PLATO))
                    {
                        item.CANTIDAD++;
                        return;
                    }
                }
            }
            else
            {
                NuevoProducto.CANTIDAD = 1;
                ListaProductos.Add(NuevoProducto);
            }
        }
コード例 #3
0
        public void EliminarProductos(int pIdProducto)
        {
            PEDIDO_PLATOS eliminaritems = new PEDIDO_PLATOS();

            using (EntitiesRestaurante entities = new EntitiesRestaurante())
            {
                eliminaritems.PLATO          = entities.PLATO.Where(n => n.ID_PLATO == pIdProducto).FirstOrDefault();
                eliminaritems.PLATO_ID_PLATO = eliminaritems.PLATO.ID_PLATO;
            }
            ListaProductos.Remove(ListaProductos.Where(c => c.PLATO.ID_PLATO == eliminaritems.PLATO.ID_PLATO).First());
        }
コード例 #4
0
        public bool insertarPedidoPlatos(PEDIDO_PLATOS pedido)
        {
            try
            {
                context.INSERTPEDIDOPLATOS(pedido.PEDIDO_ID_PEDIDO, pedido.PLATO_ID_PLATO, pedido.CANTIDAD);
                context.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #5
0
        public void CantidadDeProductos(int pIdProducto, int pCantidad)
        {
            if (pCantidad == 0)
            {
                EliminarProductos(pIdProducto);
                return;
            }
            PEDIDO_PLATOS updateProductos = new PEDIDO_PLATOS();

            updateProductos.PLATO_ID_PLATO = pIdProducto;
            foreach (PEDIDO_PLATOS item in ListaProductos)
            {
                if (item.Equals(updateProductos))
                {
                    item.CANTIDAD = pCantidad;
                    return;
                }
            }
        }