Exemple #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
        {
            string userID = Context.User.Identity.GetUserId();

            if (userID != null)
            {
                int id     = Convert.ToInt32(Request.QueryString["id"]);
                int amount = Convert.ToInt32(ddlAmt.SelectedValue);

                Cart cart = new Cart

                {
                    Amount        = amount,
                    ClientID      = userID,
                    DatePurchased = DateTime.Now,
                    IsInCart      = true,
                    ProductID     = id
                };

                Cart_Model type = new Cart_Model();
                lblResults.Text = type.InsertCart(cart);
            }
            else
            {
                lblResults.Text = "Please log in to continue to order items";
            }
        }
    }