예제 #1
0
        public static bool DeleteByStore(Guid storeGuid, DateTime olderThan)
        {
            CartOffer.DeleteByStore(storeGuid, olderThan);
            CartOrderInfo.DeleteByStore(storeGuid, olderThan);

            return(DBCart.DeleteByStore(storeGuid, olderThan));
        }
예제 #2
0
        private static List <CartOffer> LoadListFromReader(IDataReader reader)
        {
            List <CartOffer> cartOfferList = new List <CartOffer>();

            try
            {
                while (reader.Read())
                {
                    CartOffer cartOffer = new CartOffer();
                    cartOffer.ItemGuid  = new Guid(reader["ItemGuid"].ToString());
                    cartOffer.CartGuid  = new Guid(reader["CartGuid"].ToString());
                    cartOffer.OfferGuid = new Guid(reader["OfferGuid"].ToString());

                    cartOffer.TaxClassGuid = new Guid(reader["TaxClassGuid"].ToString());
                    cartOffer.OfferPrice   = Convert.ToDecimal(reader["OfferPrice"]);
                    cartOffer.AddedToCart  = Convert.ToDateTime(reader["AddedToCart"]);
                    cartOffer.Quantity     = Convert.ToInt32(reader["Quantity"]);
                    cartOffer.Name         = reader["Name"].ToString();
                    if (reader["Tax"] != DBNull.Value)
                    {
                        cartOffer.Tax = Convert.ToDecimal(reader["Tax"]);
                    }

                    cartOffer.IsDonation  = Convert.ToBoolean(reader["IsDonation"]);
                    cartOffer.MaxPerOrder = Convert.ToInt32(reader["MaxPerOrder"]);
                    cartOfferList.Add(cartOffer);
                }
            }
            finally
            {
                reader.Close();
            }

            return(cartOfferList);
        }
예제 #3
0
        public static bool Delete(Guid cartGuid)
        {
            CartOffer.DeleteByCart(cartGuid);
            CartOrderInfo.Delete(cartGuid);

            return(DBCart.DeleteCart(cartGuid));
        }
예제 #4
0
        public void DeSerializeCartOffers()
        {
            if (this.serializedCartOffers.Length == 0)
            {
                return;
            }
            ArrayList arrayList = SerializationHelper.DeserializeFromString(typeof(ArrayList),
                                                                            SerializationHelper.RestoreXmlDeclaration(this.serializedCartOffers)) as ArrayList;

            if (arrayList == null)
            {
                return;
            }

            if (this.cartOffers == null)
            {
                this.cartOffers = new List <CartOffer>();
            }

            if (this.cartOffers.Count > 0)
            {
                this.cartOffers.Clear();
            }

            foreach (string c in arrayList)
            {
                CartOffer offer = SerializationHelper.DeserializeFromString(typeof(CartOffer),
                                                                            SerializationHelper.RestoreXmlDeclaration(c)) as CartOffer;

                this.cartOffers.Add(offer);
            }
        }
예제 #5
0
        private List <CartOffer> GetCartOffers()
        {
            List <CartOffer> cartOffers = CartOffer.GetByCart(this.cartGuid);

            //IDataReader reader = DBCartOffer.GetByCart(this.cartGuid, Guid.Empty);
            //while (reader.Read())
            //{
            //    CartOffer cartOffer = new CartOffer();

            //    cartOffer.AddedToCart = Convert.ToDateTime(reader["AddedToCart"]);
            //    cartOffer.CartGuid = this.cartGuid;
            //    cartOffer.CurrencyGuid = new Guid(reader["CurrencyGuid"].ToString());
            //    cartOffer.ItemGuid = new Guid(reader["ItemGuid"].ToString());
            //    cartOffer.OfferGuid = new Guid(reader["OfferGuid"].ToString());
            //    cartOffer.OfferPrice = Convert.ToDecimal(reader["OfferPrice"]);
            //    cartOffer.PriceGuid = new Guid(reader["PriceGuid"].ToString());
            //    cartOffer.Quantity = Convert.ToInt32(reader["Quantity"]);
            //    cartOffer.TaxClassGuid = new Guid(reader["TaxClassGuid"].ToString());
            //    cartOffers.Add(cartOffer);

            //}
            //reader.Close();

            return(cartOffers);
        }
예제 #6
0
        private static List<CartOffer> LoadListFromReader(IDataReader reader)
        {
            List<CartOffer> cartOfferList = new List<CartOffer>();
            try
            {
                while (reader.Read())
                {
                    CartOffer cartOffer = new CartOffer();
                    cartOffer.itemGuid = new Guid(reader["ItemGuid"].ToString());
                    cartOffer.cartGuid = new Guid(reader["CartGuid"].ToString());
                    cartOffer.offerGuid = new Guid(reader["OfferGuid"].ToString());

                    cartOffer.taxClassGuid = new Guid(reader["TaxClassGuid"].ToString());
                    cartOffer.offerPrice = Convert.ToDecimal(reader["OfferPrice"]);
                    cartOffer.addedToCart = Convert.ToDateTime(reader["AddedToCart"]);
                    cartOffer.quantity = Convert.ToInt32(reader["Quantity"]);
                    cartOffer.name = reader["Name"].ToString();
                    if (reader["Tax"] != DBNull.Value)
                    {
                        cartOffer.tax = Convert.ToDecimal(reader["Tax"]);
                    }

                    cartOffer.isDonation = Convert.ToBoolean(reader["IsDonation"]);

                    cartOfferList.Add(cartOffer);

                }
            }
            finally
            {
                reader.Close();
            }

            return cartOfferList;
        }
예제 #7
0
파일: Cart.cs 프로젝트: saiesh86/TravelBlog
        public bool AddOfferToCart(Offer offer, int quantity)
        {
            if (offer == null) { return false; }

            bool foundOfferInCart = false;
            bool deleted = false;
            foreach (CartOffer cOffer in CartOffers)
            {
                if (cOffer.OfferGuid == offer.Guid)
                {
                    foundOfferInCart = true;
                    cOffer.Quantity += quantity;
                    if (cOffer.Quantity <= 0)
                    {
                        DBCartOffer.Delete(cOffer.ItemGuid);
                        ResetCartOffers();
                        deleted = true;
                    }
                    else
                    {
                        cOffer.Save();
                    }
                    RefreshTotals();
                    Save();
                }
            }

            if (foundOfferInCart)
            {
                return !deleted;
            }

            if (quantity <= 0) { return false; }

            CartOffer cartOffer = new CartOffer();
            cartOffer.CartGuid = this.cartGuid;
            //cartOffer.CurrencyGuid = currencyGuid;
            cartOffer.TaxClassGuid = offer.TaxClassGuid;
            cartOffer.OfferGuid = offer.Guid;
            cartOffer.OfferPrice = offer.Price;
            cartOffer.Quantity = quantity;
            // this will be updated later, just initialize to 0
            cartOffer.Tax = 0;
            cartOffer.IsDonation = offer.IsDonation;
            cartOffer.Save();

            // clear offers collection so it will be refreshed
            cartOffers = GetCartOffers();

            //CalculateSubTotal();
            //CalculatShippingTotal();
            //CalculateTaxTotal();
            //CalculateTotal();
            //Save();
            RefreshTotals();

            return true;
        }
예제 #8
0
 public List <CartOffer> GetOffers()
 {
     return(CartOffer.GetByCart(this.cartGuid));
 }
예제 #9
0
        public bool AddOfferToCart(Offer offer, int quantity)
        {
            if (offer == null)
            {
                return(false);
            }

            bool foundOfferInCart = false;
            bool deleted          = false;

            foreach (CartOffer cOffer in CartOffers)
            {
                if (cOffer.OfferGuid == offer.Guid)
                {
                    foundOfferInCart = true;
                    int newQty = cOffer.Quantity + quantity;
                    if (offer.MaxPerOrder < newQty)
                    {
                        cOffer.Quantity = offer.MaxPerOrder;
                    }
                    else
                    {
                        cOffer.Quantity = newQty;
                    }

                    if (cOffer.Quantity <= 0)
                    {
                        DBCartOffer.Delete(cOffer.ItemGuid);
                        ResetCartOffers();
                        deleted = true;
                    }
                    else
                    {
                        cOffer.Save();
                    }
                    RefreshTotals();
                    Save();
                }
            }

            if (foundOfferInCart)
            {
                return(!deleted);
            }

            if (quantity <= 0)
            {
                return(false);
            }
            if (offer.MaxPerOrder < quantity)
            {
                quantity = offer.MaxPerOrder;
            }
            CartOffer cartOffer = new CartOffer();

            cartOffer.CartGuid = this.cartGuid;
            //cartOffer.CurrencyGuid = currencyGuid;
            cartOffer.TaxClassGuid = offer.TaxClassGuid;
            cartOffer.OfferGuid    = offer.Guid;
            cartOffer.OfferPrice   = offer.Price;
            cartOffer.Quantity     = quantity;
            // this will be updated later, just initialize to 0
            cartOffer.Tax         = 0;
            cartOffer.IsDonation  = offer.IsDonation;
            cartOffer.MaxPerOrder = offer.MaxPerOrder;
            cartOffer.Save();

            // clear offers collection so it will be refreshed
            cartOffers = GetCartOffers();

            //CalculateSubTotal();
            //CalculatShippingTotal();
            //CalculateTaxTotal();
            //CalculateTotal();
            //Save();
            RefreshTotals();


            return(true);
        }