public bool UpdateCartItemQuantity(Guid itemGuid, int quantity) { foreach (CartOffer cartOffer in CartOffers) { if (cartOffer.ItemGuid == itemGuid) { int newQty = cartOffer.Quantity + quantity; if (cartOffer.MaxPerOrder < newQty) { newQty = cartOffer.MaxPerOrder; } if (quantity <= 0) { DBCartOffer.Delete(itemGuid); ResetCartOffers(); } else { cartOffer.Quantity = newQty; cartOffer.Save(); } RefreshTotals(); Save(); return(true); } } return(false); }
/// <summary> /// Updates this instance of CartOffer. Returns true on success. /// </summary> /// <returns>bool</returns> private bool Update() { return(DBCartOffer.Update( this.itemGuid, this.offerGuid, this.taxClassGuid, this.offerPrice, this.addedToCart, this.quantity, this.tax, this.isDonation)); }
public bool DeleteItem(Guid itemGuid) { bool result = DBCartOffer.Delete(itemGuid); if (result) { RefreshTotals(); Save(); } return(result); }
/// <summary> /// Updates this instance of CartOffer. Returns true on success. /// </summary> /// <returns>bool</returns> private bool Update() { return(DBCartOffer.Update( this.ItemGuid, this.OfferGuid, this.TaxClassGuid, this.OfferPrice, this.AddedToCart, this.Quantity, this.Tax, this.IsDonation, this.MaxPerOrder)); }
/// <summary> /// Persists a new instance of CartOffer. Returns true on success. /// </summary> /// <returns></returns> private bool Create() { this.itemGuid = Guid.NewGuid(); int rowsAffected = DBCartOffer.Add( this.itemGuid, this.cartGuid, this.offerGuid, this.taxClassGuid, this.offerPrice, this.addedToCart, this.quantity, this.tax, this.isDonation); return(rowsAffected > 0); }
/// <summary> /// Persists a new instance of CartOffer. Returns true on success. /// </summary> /// <returns></returns> private bool Create() { this.ItemGuid = Guid.NewGuid(); int rowsAffected = DBCartOffer.Add( this.ItemGuid, this.CartGuid, this.OfferGuid, this.TaxClassGuid, this.OfferPrice, this.AddedToCart, this.Quantity, this.Tax, this.IsDonation, this.MaxPerOrder); return(rowsAffected > 0); }
public static bool DeleteByStore(Guid storeGuid, DateTime olderThan) { return(DBCartOffer.DeleteByStore(storeGuid, olderThan)); }
public static bool DeleteByCart(Guid cartGuid) { return(DBCartOffer.DeleteByCart(cartGuid)); }
public static List <CartOffer> GetByCart(Guid cartGuid) { IDataReader reader = DBCartOffer.GetByCart(cartGuid); return(LoadListFromReader(reader)); }
public IDataReader GetItems() { return(DBCartOffer.GetByCart(this.cartGuid)); }
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); }