protected void Page_Load(object sender, EventArgs e) { using (CartAction act = new CartAction()) { double carttotal = act.GetTotal(); if (carttotal > 0) { lblTotal.Text = string.Format("{0:c}", carttotal); } else { lblTotalText.Text = ""; lblTotal.Text = ""; ShoppingcartTitle.InnerText = "Shopping Cart is Empty"; } } }
protected void Page_Load(object sender, EventArgs e) { string id = Request.QueryString["ProductId"]; int productId; if (id != null && int.TryParse(id, out productId)) { using(CartAction action = new CartAction()) { action.AddToCart(int.Parse(id)); } } else { Debug.Fail("ERROR : We should never get to AddToCart.aspx without a ProductId."); throw new Exception("ERROR : It is illegal to load AddToCart.aspx without setting a ProductId."); } Response.Redirect("ShoppingCart.aspx"); }
public List<CartItem> GetCart() { CartAction action = new CartAction(); return action.GetCartItem(); }