protected void Page_Load(object sender, EventArgs e) { this.actions = new ShoppingCartActions(); using (var usersShoppingCart = new ShoppingCartActions()) { var cartTotal = usersShoppingCart.GetTotal(); if (cartTotal > 0) { // Display Total. this.lblTotal.Text = $"{cartTotal:c}"; } else { this.LabelTotalText.Text = string.Empty; this.lblTotal.Text = string.Empty; this.ShoppingCartTitle.InnerText = "Uw winkelwagen is leeg"; this.UpdateBtn.Visible = false; this.btnCheckout.Visible = false; } } if (this.actions.GetCartItems().Count == 0) { this.btnCheckout.Enabled = false; } else { this.btnCheckout.Enabled = true; } }
public List<CartItem> UpdateCartItems() { using (var usersShoppingCart = new ShoppingCartActions()) { var cartId = usersShoppingCart.GetCartId(); var cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[this.CartList.Rows.Count]; for (var i = 0; i < this.CartList.Rows.Count; i++) { var rowValues = GetValues(this.CartList.Rows[i]); cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]); var cbRemove = (CheckBox)this.CartList.Rows[i].FindControl("Remove"); cartUpdates[i].RemoveItem = cbRemove.Checked; var quantityTextBox = (TextBox)this.CartList.Rows[i].FindControl("PurchaseQuantity"); cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text); } usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates); this.CartList.DataBind(); this.lblTotal.Text = $"{usersShoppingCart.GetTotal():c}"; return usersShoppingCart.GetCartItems(); } }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> /// <exception cref="Exception"> /// </exception> protected void Page_Load(object sender, EventArgs e) { var rawId = this.Request.QueryString["ProductID"]; int productId; if (!string.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId)) { using (var usersShoppingCart = new ShoppingCartActions()) { usersShoppingCart.AddToCart(Convert.ToInt16(rawId)); } } else { Debug.Fail("ERROR : We should never get to AddToCart.aspx without a ProductId."); } this.Response.Redirect("~/Scart.aspx"); }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load(object sender, EventArgs e) { if (!this.Page.User.Identity.IsAuthenticated) { this.Response.Redirect("~/Login.aspx"); } // Loading articles this.workingman = new ShoppingCartActions(); this.transportman = new OrderLogic(new DeliveryOracleContext(), new PickupOracleContext(), new OrderOracleContext()); // Loading user var customerLogic = new CustomerLogic(new CustomerOracleContext()); this.currentCustomer = customerLogic.GetByEmail(HttpContext.Current.User.Identity.Name); // Put information in form this.HcustomerID.Value = this.currentCustomer.Id.ToString(); this.txtName.Text = this.currentCustomer.Name; this.txtAddress.Text = this.currentCustomer.Address; this.txtPostalCode.Text = this.currentCustomer.Postalcode; this.txtCity.Text = this.currentCustomer.City; this.txtTelePhoneNumber.Text = this.currentCustomer.Telephone; this.txtEmailAddress.Text = this.currentCustomer.Emailaddress; // Loading list of stores for picking up this.storeLogic = new StoreLogic(new StoreOracleContext()); foreach (var store in storeLogic.GetAllStores()) { this.drpStores.Items.Add("MyCom - " + store.Address); } // Loading fields for delivery this.txtAlterAddress.Text = this.currentCustomer.Address; this.txtAlterCity.Text = this.currentCustomer.City; this.txtAlterPostal.Text = this.currentCustomer.Postalcode; }
/// <summary> /// The get cart. /// </summary> /// <param name="context"> /// The context. /// </param> /// <returns> /// The <see cref="ShoppingCartActions"/>. /// </returns> public ShoppingCartActions GetCart(HttpContext context) { using (var cart = new ShoppingCartActions()) { cart.ShoppingCartId = cart.GetCartId(); return cart; } }