Exemple #1
0
        public List <SepetUrun> GetSepetItems()
        {
            Sepetim usersShoppingCart = new Sepetim();
            string  sepetID           = usersShoppingCart.SepetIdAl();

            if (sepetID == null)
            {
                LabelTotalText.Text         = "";
                lblTotal.Text               = "";
                ShoppingCartTitle.InnerText = "Sepetiniz Boş";
                UpdateBtn.Visible           = false;
                CheckoutBtn.Visible         = false;
                return(null);
            }
            var items = usersShoppingCart.SepetItems(sepetID);

            decimal sepetTutari = items.Sum(od => od.Miktar * od.Urun.BirimFiyat);

            if (sepetTutari > 0)
            {
                lblTotal.Text = string.Format("{0:c}", sepetTutari);
                return(items.Select(x => new SepetUrun {
                    Miktar = x.Miktar, BirimFiyat = x.Urun.BirimFiyat, Ad = x.Urun.Ad, Id = x.Urun.Id
                }).ToList());
            }
            else
            {
                LabelTotalText.Text         = "";
                lblTotal.Text               = "";
                ShoppingCartTitle.InnerText = "Sepetiniz Boş";
                UpdateBtn.Visible           = false;
                CheckoutBtn.Visible         = false;
                return(null);
            }
        }
Exemple #2
0
        protected void UpdateBtn_Click(object sender, ImageClickEventArgs e)
        {
            Sepetim usersShoppingCart = new Sepetim();
            string  sepetID           = usersShoppingCart.SepetIdAl();

            SepetGüncelleme[] sepetUpdates = new SepetGüncelleme[grdListe.Rows.Count];
            for (int i = 0; i < grdListe.Rows.Count; i++)
            {
                IOrderedDictionary rowValues = new OrderedDictionary();
                rowValues = GetValues(grdListe.Rows[i]);
                sepetUpdates[i].UrunId = Convert.ToInt32(rowValues["Id"]);

                sepetUpdates[i].AlimMiktari = Convert.ToInt16(rowValues["Miktar"]);

                CheckBox cbRemove = (CheckBox)grdListe.Rows[i].FindControl("chkCikar");
                sepetUpdates[i].UrunCikar = cbRemove.Checked;
            }

            usersShoppingCart.SepetiVeritabanındaGüncelle(sepetID, sepetUpdates);
            grdListe.DataBind();
        }