Ejemplo n.º 1
0
    private void Btn_Click(object sender, EventArgs e)
    {
        Session["Count"] = (int)Session["Count"] + 1;
        Button thisbtn = (Button)sender;

        int id = int.Parse(thisbtn.ID);

        var i = AllProducts.FindIndex(a => a.ID == id);

        //  int[] v = MyProducts.Select((b, y) => b.ID == id ? i : -1).Where(y => y != -1).ToArray();


        //   var itwice = MyProducts.FindIndex(a => a.ID == id);

        //   if (itwice != -1)
        //   {
        //      int tmp = MyProducts.Count +1 ;

        //     var x = MyProducts.FindIndex(a => a.ID == tmp);

        //      MyProducts.AddItem(tmp, AllProducts[i].IdProduct, AllProducts[i].Name, AllProducts[i].Description, AllProducts[i].Quantity, AllProducts[i].Ingriedients, AllProducts[i].Price, AllProducts[i].Notes, AllProducts[i].IsFrozen, AllProducts[i].ImgUri);
        //  }

        //else
        MyProducts.AddItem((int)Session["Count"], AllProducts[i].IdProduct, AllProducts[i].Name, AllProducts[i].Description, AllProducts[i].Quantity, AllProducts[i].Ingriedients, AllProducts[i].Price, AllProducts[i].Notes, AllProducts[i].IsFrozen, AllProducts[i].ImgUri);



        double thisValue = AllProducts[i].Price;

        // string txt = total_cart.InnerText.ToString().Remove(0, 1);
        //double txtValue = Convert.ToDouble(txt);

        Session["TotalCart"]      = Convert.ToDouble(Session["TotalCart"]) + thisValue;
        total_cart.InnerText      = "Carrello: €" + Convert.ToDouble(Session["TotalCart"]);
        carrello_mobile.InnerText = "Carrello: €" + Convert.ToDouble(Session["TotalCart"]);

        Session["MyCart"] = MyProducts;
        //Session["TotalCart"] = MyProducts;
        //Session["TotalCart"]
        //ic++;
        //Button tmpbtn = (Button)sender;
        //string[] tmp = tmpbtn.ID.Split(';');
        //cartitems.AddItem(ic, Convert.ToInt32(tmp[1]), Convert.ToDouble(tmp[0]));

        ////only desktop price


        //string i = total_cart.InnerText.ToString();
        //string i1 = total_cart.InnerText.ToString().Remove(0, 1);

        //double value = Convert.ToDouble(i1);
        //value += Convert.ToDouble(tmp[1]);
        //Session["TotalCart"] = Convert.ToDouble(Session["TotalCart"]) + value;

        //total_cart.InnerText = "€" + Convert.ToDouble(Session["TotalCart"]);
    }
Ejemplo n.º 2
0
        public ActionResult AddItem(IEnumerable <HttpPostedFileBase> uploads, AdminItem item)
        {
            Category category = new Category();

            ViewBag.Category = category.GetCategories();

            if (ModelState.IsValid)
            {
                Products products = new Products();
                products.AddItem(uploads, item);

                return(RedirectToAction("Index"));
            }

            return(View());
        }