public CouponCollection FetchAll() { CouponCollection coll = new CouponCollection(); Query qry = new Query(Coupon.Schema); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
private void LoadCoupons() { List <Coupon> coupons = CouponCollection.GetAll(StoreContext.CurrentStore.Id.Value); rptCoupons.DataSource = coupons; rptCoupons.DataBind(); }
public CouponCollection GetCoupons() { CouponCollection collection = new CouponCollection(); // Build Mock Coupon Collection collection.Add(new BuyGetCoupon("C1", "1", 4, 1) { }); collection.Add(new TotalDiscountCoupon("C2", 10f) { }); return(collection); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event to initialize the page. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param> protected override void OnInit(EventArgs e) { Label lblBillingInformation = acCheckout.Panes[0].FindControl("lblBillingInformation") as Label; Label lblShippingInformation = acCheckout.Panes[1].FindControl("lblShippingInformation") as Label; Label lblShippingMethod = acCheckout.Panes[2].FindControl("lblShippingMethod") as Label; Label lblCouponInformation = acCheckout.Panes[3].FindControl("lblCouponInformation") as Label; Label lblOrderReview = acCheckout.Panes[4].FindControl("lblOrderReview") as Label; //See if there are any coupons in the system //If not, then don't display the coupon stuff couponCollection = new CouponController().FetchAll(); if (couponCollection.Count == 0) { hasCoupons = false; acpCoupon.Visible = false; pnlCouponInformationDisplayTitle.Visible = false; pnlCouponInformationDisplay.Visible = false; } shippingService = new ShippingService(); if (!shippingService.ShippingServiceSettings.UseShipping) { acCheckout.Panes[1].Visible = false; acCheckout.Panes[2].Visible = false; pnlShippingAddressDisplayTitle.Visible = false; pnlShippingAddressDisplay.Visible = false; pnlShippingMethodDisplayTitle.Visible = false; pnlShippingMethodDisplay.Visible = false; } order = new OrderController().FetchOrder(WebUtility.GetUserName()); if (!Page.IsPostBack) { SetBillingAddressDisplay(); SetShippingAddressDisplay(); SetShippingMethodDisplay(); SetCouponDisplay(); } base.OnInit(e); }
public static CouponCollection LoadForShipMethod(Int32 shipMethodId, int maximumRows, int startRowIndex, string sortExpression) { //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + Coupon.GetColumnNames("ac_Coupons")); selectQuery.Append(" FROM ac_Coupons, ac_CouponShipMethods"); selectQuery.Append(" WHERE ac_Coupons.CouponId = ac_CouponShipMethods.CouponId"); selectQuery.Append(" AND ac_CouponShipMethods.ShipMethodId = @shipMethodId"); selectQuery.Append(" AND StoreId = @storeId"); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@shipMethodId", System.Data.DbType.Int32, shipMethodId); database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, Token.Instance.StoreId); //EXECUTE THE COMMAND CouponCollection results = new CouponCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { Coupon coupon = new Coupon(); Coupon.LoadDataReader(coupon, dr); results.Add(coupon); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
public static CouponCollection LoadForCriteria(string sqlCriteria, int maximumRows, int startRowIndex, string sortExpression) { //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + Coupon.GetColumnNames(string.Empty)); selectQuery.Append(" FROM ac_Coupons"); string whereClause = string.IsNullOrEmpty(sqlCriteria) ? string.Empty : " WHERE " + sqlCriteria; selectQuery.Append(whereClause); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); //EXECUTE THE COMMAND CouponCollection results = new CouponCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { Coupon coupon = new Coupon(); Coupon.LoadDataReader(coupon, dr); results.Add(coupon); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
protected async override Task <bool> GetDataAsync() { if (!Context.CatalogId.HasValue) { throw new Exception("CatalogId is required"); } var couponResource = new CouponResource(Context); if (string.IsNullOrEmpty(CouponSetCode)) { throw new Exception("CouponSetCode is requried to get Coupons"); } _results = await couponResource.GetCouponsAsync(CouponSetCode, startIndex : StartIndex, pageSize : PageSize, sortBy : SortBy, filter : Filter, responseFields : ResponseFields, includeCounts : IncludeCounts); TotalCount = _results.TotalCount; PageCount = _results.PageCount; PageSize = _results.PageSize; return(_results.Items != null && _results.Items.Count > 0); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event to initialize the page. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param> protected override void OnInit(EventArgs e) { if (Master.SiteSettings.LoginRequirement == LoginRequirement.Checkout) { if (!User.Identity.IsAuthenticated) { Response.Redirect("login.aspx?ReturnUrl=/checkout.aspx", true); } } PaymentService paymentService = new PaymentService(); if (paymentService.PaymentServiceSettings.DefaultProvider == "PayPalStandardPaymentProvider") { Response.Redirect("~/paypalcheckout.aspx", true); } //Keep these here - the Accordion ViewState is funky and requires things to be set early Label lblBillingInformation = acCheckout.Panes[0].FindControl("lblBillingInformation") as Label; Label lblShippingInformation = acCheckout.Panes[1].FindControl("lblShippingInformation") as Label; Label lblShippingMethod = acCheckout.Panes[2].FindControl("lblShippingMethod") as Label; Label lblCouponInformation = acCheckout.Panes[3].FindControl("lblCouponInformation") as Label; Label lblPaymentInformation = acCheckout.Panes[4].FindControl("lblPaymentInformation") as Label; Label lblOrderReview = acCheckout.Panes[5].FindControl("lblOrderReview") as Label; //See if there are any coupons in the system //If not, then don't display the coupon stuff couponCollection = new CouponController().FetchAll(); if (couponCollection.Count == 0) { hasCoupons = false; acpCoupon.Visible = false; pnlCouponInformationDisplayTitle.Visible = false; pnlCouponInformationDisplay.Visible = false; } shippingService = new ShippingService(); if (!shippingService.ShippingServiceSettings.UseShipping) { acCheckout.Panes[1].Visible = false; acCheckout.Panes[2].Visible = false; pnlShippingAddressDisplayTitle.Visible = false; pnlShippingAddressDisplay.Visible = false; pnlShippingMethodDisplayTitle.Visible = false; pnlShippingMethodDisplay.Visible = false; } //Keep these here - the Accordion ViewState is funky and requires things to be set early order = new OrderController().FetchOrder(WebUtility.GetUserName()); #region PayPal Express Checkout Logic if (!string.IsNullOrEmpty(order.PaymentMethod)) { if (order.PaymentMethod == "PayPal") { string token = Utility.GetParameter("token"); if (!string.IsNullOrEmpty(token)) { pnlCreditCardInformation.Visible = false; pnlCreditCardInfo.Visible = false; lblCreditCardType.Text = order.PaymentMethod; ddlCreditCardType.SelectedValue = "4"; ddlCreditCardType.Enabled = false; PayPalPayer payPalPayer = OrderController.GetExpressCheckout(token); if (order.BillingAddress == null) {//Then they are coming in from the cart.aspx ExpressCheckout button //copy the PayPalPayer ShippingAddress and then flag it as a BillingAddress Address billingAddress = new Address(payPalPayer.ShippingAddress); billingAddress.AddressType = AddressType.BillingAddress; Address duplicateBillingAddress = WebProfile.Current.AddressCollection.Find( addressToFind => addressToFind.ToString() == billingAddress.ToString() && addressToFind.AddressType == AddressType.BillingAddress); if (duplicateBillingAddress == null) { WebProfile.Current.AddressCollection.Add(billingAddress); WebProfile.Current.Save(); } order.BillToAddress = payPalPayer.ShippingAddress.ToXml(); } if (!payPalPayer.ShippingAddress.Equals(order.ShippingAddress)) { Address shippingAddress = new Address(payPalPayer.ShippingAddress); shippingAddress.AddressType = AddressType.ShippingAddress; Address duplicateShippingAddress = WebProfile.Current.AddressCollection.Find( addressToFind => addressToFind.ToString() == shippingAddress.ToString() && addressToFind.AddressType == AddressType.ShippingAddress); if (duplicateShippingAddress == null) { WebProfile.Current.AddressCollection.Add(shippingAddress); WebProfile.Current.Save(); } order.ShipToAddress = payPalPayer.ShippingAddress.ToXml(); } if (order.ExtendedProperties.ContainsKey(PAYPAL_PAYER_ID)) { order.ExtendedProperties.Remove(PAYPAL_PAYER_ID); } if (order.ExtendedProperties.ContainsKey(PAYPAL_TOKEN)) { order.ExtendedProperties.Remove(PAYPAL_TOKEN); } order.ExtendedProperties.Add(PAYPAL_PAYER_ID, payPalPayer.PayPalPayerId); order.ExtendedProperties.Add(PAYPAL_TOKEN, payPalPayer.PayPalToken); order.AdditionalProperties = order.ExtendedProperties.ToXml(); order.Save(WebUtility.GetUserName()); OrderController.CalculateTax(WebUtility.GetUserName()); order = new OrderController().FetchOrder(WebUtility.GetUserName()); } } } #endregion if (!Page.IsPostBack) { SetBillingAddressDisplay(); SetShippingAddressDisplay(); SetShippingMethodDisplay(); SetCouponDisplay(); SetPaymentMethodDisplay(-1, order.CreditCardNumber, DateTime.MinValue); } base.OnInit(e); }
public CouponCollection FetchByQuery(Query qry) { CouponCollection coll = new CouponCollection(); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
public CouponCollection FetchByID(object CouponId) { CouponCollection coll = new CouponCollection().Where("CouponId", CouponId).Load(); return coll; }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event to initialize the page. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param> protected override void OnInit(EventArgs e) { if (Master.SiteSettings.LoginRequirement == LoginRequirement.Checkout) { if (!User.Identity.IsAuthenticated) { Response.Redirect("login.aspx?ReturnUrl=/checkout.aspx", true); } } PaymentService paymentService = new PaymentService(); if (paymentService.PaymentServiceSettings.DefaultProvider == "PayPalStandardPaymentProvider") { Response.Redirect("~/paypalcheckout.aspx", true); } //Keep these here - the Accordion ViewState is funky and requires things to be set early Label lblBillingInformation = acCheckout.Panes[0].FindControl("lblBillingInformation") as Label; Label lblShippingInformation = acCheckout.Panes[1].FindControl("lblShippingInformation") as Label; Label lblShippingMethod = acCheckout.Panes[2].FindControl("lblShippingMethod") as Label; Label lblCouponInformation = acCheckout.Panes[3].FindControl("lblCouponInformation") as Label; Label lblPaymentInformation = acCheckout.Panes[4].FindControl("lblPaymentInformation") as Label; Label lblOrderReview = acCheckout.Panes[5].FindControl("lblOrderReview") as Label; //See if there are any coupons in the system //If not, then don't display the coupon stuff couponCollection = new CouponController().FetchAll(); if (couponCollection.Count == 0) { hasCoupons = false; acpCoupon.Visible = false; pnlCouponInformationDisplayTitle.Visible = false; pnlCouponInformationDisplay.Visible = false; } shippingService = new ShippingService(); if (!shippingService.ShippingServiceSettings.UseShipping) { acCheckout.Panes[1].Visible = false; acCheckout.Panes[2].Visible = false; pnlShippingAddressDisplayTitle.Visible = false; pnlShippingAddressDisplay.Visible = false; pnlShippingMethodDisplayTitle.Visible = false; pnlShippingMethodDisplay.Visible = false; } //Keep these here - the Accordion ViewState is funky and requires things to be set early order = new OrderController().FetchOrder(WebUtility.GetUserName()); #region PayPal Express Checkout Logic if (!string.IsNullOrEmpty(order.PaymentMethod)) { if (order.PaymentMethod == "PayPal") { string token = Utility.GetParameter("token"); if (!string.IsNullOrEmpty(token)) { pnlCreditCardInformation.Visible = false; pnlCreditCardInfo.Visible = false; lblCreditCardType.Text = order.PaymentMethod; ddlCreditCardType.SelectedValue = "4"; ddlCreditCardType.Enabled = false; PayPalPayer payPalPayer = OrderController.GetExpressCheckout(token); if (order.BillingAddress == null)//Then they are coming in from the cart.aspx ExpressCheckout button //copy the PayPalPayer ShippingAddress and then flag it as a BillingAddress { Address billingAddress = new Address(payPalPayer.ShippingAddress); billingAddress.AddressType = AddressType.BillingAddress; Address duplicateBillingAddress = WebProfile.Current.AddressCollection.Find( addressToFind => addressToFind.ToString() == billingAddress.ToString() && addressToFind.AddressType == AddressType.BillingAddress); if (duplicateBillingAddress == null) { WebProfile.Current.AddressCollection.Add(billingAddress); WebProfile.Current.Save(); } order.BillToAddress = payPalPayer.ShippingAddress.ToXml(); } if (!payPalPayer.ShippingAddress.Equals(order.ShippingAddress)) { Address shippingAddress = new Address(payPalPayer.ShippingAddress); shippingAddress.AddressType = AddressType.ShippingAddress; Address duplicateShippingAddress = WebProfile.Current.AddressCollection.Find( addressToFind => addressToFind.ToString() == shippingAddress.ToString() && addressToFind.AddressType == AddressType.ShippingAddress); if (duplicateShippingAddress == null) { WebProfile.Current.AddressCollection.Add(shippingAddress); WebProfile.Current.Save(); } order.ShipToAddress = payPalPayer.ShippingAddress.ToXml(); } if (order.ExtendedProperties.ContainsKey(PAYPAL_PAYER_ID)) { order.ExtendedProperties.Remove(PAYPAL_PAYER_ID); } if (order.ExtendedProperties.ContainsKey(PAYPAL_TOKEN)) { order.ExtendedProperties.Remove(PAYPAL_TOKEN); } order.ExtendedProperties.Add(PAYPAL_PAYER_ID, payPalPayer.PayPalPayerId); order.ExtendedProperties.Add(PAYPAL_TOKEN, payPalPayer.PayPalToken); order.AdditionalProperties = order.ExtendedProperties.ToXml(); order.Save(WebUtility.GetUserName()); OrderController.CalculateTax(WebUtility.GetUserName()); order = new OrderController().FetchOrder(WebUtility.GetUserName()); } } } #endregion if (!Page.IsPostBack) { SetBillingAddressDisplay(); SetShippingAddressDisplay(); SetShippingMethodDisplay(); SetCouponDisplay(); SetPaymentMethodDisplay(-1, order.CreditCardNumber, DateTime.MinValue); } base.OnInit(e); }