Example #1
0
        public static void AddOrUpdate(int productID, int AMOUNT, int ISEQUAL = 0)
        {
            if (AMOUNT > 0 && productID > 0)
            {
                if (myBasket != null)
                {
                    BasketModelList BL = myBasket;

                    if (Control(productID))
                    {
                        if (ISEQUAL.ToBoolean())                          // Eşitler
                        {
                            BL.BasketList.Where(x => x.PRODUCT.ID == productID).ToList()[0].AMOUNT = AMOUNT;
                        }
                        else                         // Üstüne Ekler
                        {
                            BL.BasketList.Where(x => x.PRODUCT.ID == productID).ToList()[0].AMOUNT += AMOUNT;
                        }

                        myBasket = BL;
                    }
                    else
                    {
                        TBL_PRODUCTS P = TBL_PRODUCTS.SINGLE(productID, ISACTIVE: true);
                        if (P != null)                         // ÜRÜN SİSTEMDE VARSA İŞLEM YAP
                        {
                            BasketModel BM = new BasketModel();
                            BM.PRODUCT = P;
                            BM.AMOUNT  = AMOUNT;

                            BL.BasketList.Add(BM);
                            myBasket = BL;
                        }
                    }
                }
                else
                {
                    TBL_PRODUCTS P = TBL_PRODUCTS.SINGLE(productID, ISACTIVE: true);
                    if (P != null)                     // ÜRÜN SİSTEMDE VARSA İŞLEM YAP
                    {
                        BasketModel BM = new BasketModel();
                        BM.PRODUCT = P;
                        BM.AMOUNT  = AMOUNT;

                        BasketModelList BL = new BasketModelList();
                        BL.BasketList = new List <BasketModel>()
                        {
                            BM
                        };
                        myBasket = BL;
                    }
                }
            }
        }
Example #2
0
 public static void Delete(int productID)
 {
     if (myBasket != null)
     {
         if (Control(productID))
         {
             BasketModelList BL = myBasket;
             BL.BasketList.RemoveAll(x => x.PRODUCT.ID == productID);
             myBasket = BL;
         }
     }
 }