public JsonResult PersonalizarPlatillos(string RidProdCustom, string Comentarios, string Accion, List <string> chkValues)
        {
            int    id;
            double SubTotal = 0;

            if (RidProdCustom != null)
            {
                id = Convert.ToInt32(RidProdCustom);
                List <ProductosPedidos> ListadoPlatillos;
                ProductosPedidos        NewProducto = new ProductosPedidos();
                if (Session["ListadoPlatillos"] == null)
                {
                    ListadoPlatillos = new List <ProductosPedidos>();
                }
                else
                {
                    ListadoPlatillos = Session["ListadoPlatillos"] as List <ProductosPedidos>;
                }
                if (id > 0)
                {
                    if (Accion.Equals("Agregar"))
                    {
                        ListadoPlatillos.Find(x => x.ID == id).Observaciones = Comentarios;
                    }
                    else
                    {
                        ListadoPlatillos.Find(x => x.ID == id).Observaciones = "";
                    }
                    if (chkValues.Count > 0)
                    {
                        for (int i = 1; i < chkValues.Count; i++)
                        {
                            ListadoPlatillos.Find(x => x.ID == id).ComplementodeProducto[i - 1].Seleccionado = Convert.ToBoolean(Convert.ToInt32(chkValues[i]));
                        }
                    }
                    Session["ListadoPlatillos"] = ListadoPlatillos;
                }
                if (Session["ListadoPlatillos"] != null)
                {
                    for (int i = 0; i < ListadoPlatillos.Count(); i++)
                    {
                        SubTotal += ListadoPlatillos[i].Precio * ListadoPlatillos[i].Cantidad;
                    }
                    Session["SubTotal"] = SubTotal.ToString("###,##0.00");
                    return(Json("", JsonRequestBehavior.AllowGet));
                }
            }
            return(Json("", JsonRequestBehavior.AllowGet));
        }
 public ActionResult MostrarPlatillos(int?id)
 {
     if (Session["IsMesero"] != null)
     {
         ViewBag.IsMesero = true;
     }
     if (id != null)
     {
         List <ProductosPedidos> ListadoPlatillos;
         ProductosPedidos        NewProducto = new ProductosPedidos();
         double SubTotal = 0;
         if (Session["ListadoPlatillos"] == null)
         {
             ListadoPlatillos = new List <ProductosPedidos>();
         }
         else
         {
             ListadoPlatillos = Session["ListadoPlatillos"] as List <ProductosPedidos>;
         }
         if (id != null)
         {
             if (id > 0)
             {
                 if (ListadoPlatillos.Exists(x => x.ID == id.Value))
                 {
                     ListadoPlatillos.Find(x => x.ID == id.Value).Cantidad += 1;
                 }
                 else
                 {
                     NewProducto.ID       = id.Value;
                     NewProducto.Cantidad = 1;
                     ListadoPlatillos.Add(NewProducto);
                 }
                 Session["ListadoPlatillos"] = ListadoPlatillos;
             }
             if (id < 0)
             {
                 ListadoPlatillos.Find(x => x.ID == (id.Value * -1)).Cantidad += -1;
                 if (ListadoPlatillos.Find(x => x.ID == (id.Value * -1)).Cantidad < 1)
                 {
                     ListadoPlatillos.Remove(ListadoPlatillos.Find(x => x.ID == (id.Value * -1)));
                 }
                 if (ListadoPlatillos == null || ListadoPlatillos.Count == 0)
                 {
                     Session["ListadoPlatillos"] = null;
                 }
                 else
                 {
                     Session["ListadoPlatillos"] = ListadoPlatillos;
                 }
             }
         }
         if (Session["ListadoPlatillos"] != null)
         {
             int        i       = 0;
             List <int> AddProd = new List <int>();
             foreach (var item in ListadoPlatillos)
             {
                 AddProd.Add(item.ID);
             }
             List <Productos> productos = this.ARService.BuscarProductos(AddProd);
             for (i = 0; i < productos.Count(); i++)
             {
                 ListadoPlatillos.Find(x => x.ID == productos[i].ID).Producto     = productos[i].Producto;
                 ListadoPlatillos.Find(x => x.ID == productos[i].ID).Descripcion  = productos[i].Descripcion;
                 ListadoPlatillos.Find(x => x.ID == productos[i].ID).Precio       = productos[i].Precio;
                 ListadoPlatillos.Find(x => x.ID == productos[i].ID).UnidadMedida = productos[i].UnidadMedida;
                 SubTotal += ListadoPlatillos.Find(x => x.ID == productos[i].ID).Precio *ListadoPlatillos.Find(x => x.ID == productos[i].ID).Cantidad;
             }
             List <ComplementoProductos> complementos = this.ARService.BuscarProductosComplementarios(AddProd);
             if (complementos != null)
             {
                 if (complementos.Count() > 0)
                 {
                     for (i = 0; i < AddProd.Count(); i++)
                     {
                         if (ListadoPlatillos.Find(x => x.ID == AddProd[i]).ComplementodeProducto == null)
                         {
                             IEnumerable <ComplementoProductos> xComplementos = complementos.Where(x => x.idProducto == AddProd[i]);
                             List <ComplementoProductos>        xComplemento  = new List <ComplementoProductos>();
                             for (int e = 0; e < xComplementos.Count(); e++)
                             {
                                 xComplemento.Add(xComplementos.ElementAt(e) as ComplementoProductos);
                             }
                             ListadoPlatillos.Find(x => x.ID == AddProd[i]).ComplementodeProducto = xComplemento;
                         }
                     }
                 }
             }
             ViewBag.SubTotal    = SubTotal.ToString("###,##0.00");
             Session["SubTotal"] = SubTotal.ToString("###,##0.00");
             return(PartialView("_MostrarPlatillos", ListadoPlatillos));
         }
         //return View(this.ARService.GetProductos(id.Value));
     }
     ViewBag.ListadoPlatillos = Session["ListadoPlatillos"];
     return(PartialView("_MostrarPlatillos"));
 }