protected void addToCartButton_Click(object sender, EventArgs e) { int id = Int32.Parse(Request.QueryString["id"]), Quantity = 0; string messageError = ""; messageError = CartController.Add(addToCartQuantityTxt.Text, id); if (messageError != "") { labelErrorAddToCart.Text = messageError; } else { User user = (User)Session[Constant.Keys.AUTH]; Quantity = int.Parse(addToCartQuantityTxt.Text); Product product = ProductHandler.get(id); if (CartHandler.get(user.ID, product.ID) != null) { CartHandler.updateQuantity(user.ID, id, Quantity); } else { CartInformation currentProduct = new CartInformation(); currentProduct.ID = product.ID; currentProduct.Name = product.Name; currentProduct.Price = product.Price; currentProduct.Quantity = Quantity; currentProduct.SubTotal = currentProduct.Quantity * currentProduct.Price; CartHandler.add(user.ID, id, Quantity); } var redirecTo = Constant.Routes.VIEW_CART_ROUTE; Response.Redirect(redirecTo); } }