/// <summary> /// Handles the Click event of the btnAddToCart control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected void btnAddToCart_Click(object sender, EventArgs e) { if (Master.SiteSettings.LoginRequirement == LoginRequirement.Add_To_Cart) { if (!User.Identity.IsAuthenticated) { Response.Redirect(string.Format("login.aspx?ReturnUrl={0}", Request.Url), true); } } int quantity; if (ddlQuantity.Visible) { int.TryParse(ddlQuantity.SelectedValue, out quantity); } else { int.TryParse(txtQuantity.Text.Trim(), out quantity); } if (quantity > 0) { string sku = productAttributes.GetSku(); decimal pricePaid = _product.OurPrice; Store.AttributeCollection selectedAttributes = productAttributes.SelectedAttributes; foreach (Store.Attribute attribute in selectedAttributes) { foreach (AttributeItem attributeItem in attribute.AttributeItemCollection) { pricePaid += attributeItem.Adjustment; } } //string selectAttributesString = selectedAttributes.ToString(); OrderController orderController = new OrderController(); orderController.AddItemToOrder(WebUtility.GetUserName(), _product.ProductId, _product.Name, sku, quantity, pricePaid, _product.ItemTax, _product.Weight, selectedAttributes.ToString(), selectedAttributes.ExtentedProperties.ToXml()); Response.Redirect("~/cart.aspx", true); } }