Example #1
0
        public void AddToCart()
        {
            HttpContextAccessor accessor = new HttpContextAccessor();
            ShoppingCartActions actions  = new ShoppingCartActions(_mySqlDbContext);

            actions.AddToCart(accessor.HttpContext, 1);
        }
        public ActionResult AddCart(int id, int cartQuantity)
        {
            ShoppingCartActions cart = new ShoppingCartActions();

            cart.AddToCart(id, cartQuantity);
            return(RedirectToAction("Cart"));
        }
Example #3
0
        //Finish and checkout button
        protected void Unnamed2_Click(object sender, EventArgs e)
        {
            ShoppingCartActions actions = new ShoppingCartActions();

            actions.AddToCart(RadioButtonList1.SelectedIndex + 1);

            Server.Transfer("Cart.aspx");
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string plId = Request.QueryString["pricelistItemID"];
            int    pricelistItemId;
            string tpId = Request.QueryString["templateID"];
            int    templateId;
            string blId = Request.QueryString["bundleID"];
            int    bundleId;
            string qnt = Request.QueryString["quantity"];
            int    quantity;

            if (!String.IsNullOrEmpty(qnt) && int.TryParse(qnt, out quantity))
            {
                if (!String.IsNullOrEmpty(plId) && int.TryParse(plId, out pricelistItemId))
                {
                    using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                    {
                        usersShoppingCart.AddToCart(Convert.ToInt16(plId), quantity);
                    }
                    Response.Redirect("Pricelist.aspx");
                }
                else if (!String.IsNullOrEmpty(tpId) && int.TryParse(tpId, out templateId))
                {
                    using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                    {
                        var _db   = new BomShopping2.Data.BomShoppingContext();
                        var query = _db.Templates.Find(templateId);
                        foreach (PricelistItem i in query.Items)
                        {
                            usersShoppingCart.AddToCart(Convert.ToInt16(i.PricelistItemID), quantity);
                        }
                    }
                    Response.Redirect("TemplateList.aspx");
                }
                else if (!String.IsNullOrEmpty(blId) && int.TryParse(blId, out bundleId))
                {
                    using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                    {
                        var _db   = new BomShopping2.Data.BomShoppingContext();
                        var query = _db.Bundles.Find(bundleId);
                        foreach (Template t in query.Templates)
                        {
                            foreach (PricelistItem i in t.Items)
                            {
                                usersShoppingCart.AddToCart(Convert.ToInt16(i.PricelistItemID), quantity);
                            }
                        }
                    }
                    Response.Redirect("BundleList.aspx");
                }
            }
            else
            {
                Debug.Fail("ERROR : We should never get to AddToCart.aspx without a pricelistItemID.");
                throw new Exception("ERROR : It is illegal to load AddToCart.aspx without setting a pricelistItemID.");
            }
            Response.Redirect("ShoppingCart.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];
            int    productId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    int tempId      = Convert.ToInt16(rawId);
                    var productItem = _db.Products.SingleOrDefault(
                        c => c.ProductID == tempId);
                    categoryId = (int)productItem.CategoryID;
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            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.");
            }

            //TODO if Category = x then Redirect to
            //Response.Redirect("ConfiguratorProcessors.aspx");

            switch (categoryId)
            {
            case 1:
                Response.Redirect("Processors.aspx");
                break;

            case 2:
                Response.Redirect("GraphicsCards.aspx");
                break;

            case 3:
                Response.Redirect("HardDrives.aspx");
                break;

            case 4:
                Response.Redirect("Cases.aspx");
                break;

            case 5:
                Response.Redirect("KeyboardsandMouses.aspx");
                break;

            case 6:
                Response.Redirect("KeyboardsandMouses.aspx");
                break;

            default:
                Response.Redirect("Configurator.aspx");
                break;
            }
        }
        public RedirectResult AddToCart(int productId)
        {
            var cartId = new Helpers.CartHelpers().GetCartId();

            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions(cartId))
            {
                usersShoppingCart.AddToCart(productId);
            }
            return(Redirect("Index"));
        }
Example #7
0
        //Add screen button
        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            ShoppingCartActions actions = new ShoppingCartActions();

            actions.AddToCart(RadioButtonList1.SelectedIndex + 1);

            TextBox1.Text = "";
            RadioButtonList1.ClearSelection();
            FileUpload1.Attributes.Clear();
        }
Example #8
0
        public async Task <RedirectResult> AddToCart(int productId)
        {
            var cartId = new Helpers.CartHelpers().GetCartId(HttpContext);

            var usersShoppingCart = new ShoppingCartActions(_db, cartId);

            await usersShoppingCart.AddToCart(productId);

            return(Redirect("Index"));
        }
Example #9
0
        public async Task <RedirectResult> AddToCart(int itemId)
        {
            var cartId = new Helpers.CartHelpers().GetCartId();

            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions(cartId, databaseId, client, items, categories))
            {
                await usersShoppingCart.AddToCart(itemId);
            }

            return(Redirect("Index"));
        }
Example #10
0
        protected void AddToCartAction(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            ShoppingCartActions actions = new ShoppingCartActions();

            actions.AddToCart(Int32.Parse(btn.CommandArgument));
            var master = Master as SiteMaster;

            if (master != null)
            {
                master.GetCartQuantity();
            }
        }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["BookID"];
            int    bookId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out bookId))
            {
                using (ShoppingCartActions usersShoppingCart = new
                                                               ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }

            Response.Redirect("ShoppingCart.aspx");
        }
Example #12
0
        // GET: Products/AddToCart/5
        public async Task <IActionResult> AddToCart(int?id)
        {
            HttpContext.Session.SetString("a", "b");
            if (id == null)
            {
                return(NotFound());
            }

            var product = await _context.Products.SingleOrDefaultAsync(m => m.ID == id);

            if (product == null)
            {
                return(NotFound());
            }
            usersShoppingCart.AddToCart(product.ID, this.User.FindFirstValue(ClaimTypes.NameIdentifier));
            return(RedirectToAction("Index"));
        }
Example #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];
            int    productId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                ShoppingCartActions usersShoppingCart = new ShoppingCartActions();
                usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
            }
            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");
        }
Example #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];
            int    tempId;

            if (!string.IsNullOrEmpty(rawId) && int.TryParse(rawId, out tempId))
            {
                using (ShoppingCartActions usershopcart = new ShoppingCartActions())
                    usershopcart.AddToCart(Convert.ToInt16(rawId));
            }
            else
            {
                throw new Exception("Error: you should setting a ProductId.");
            }

            Response.Redirect("/Views/ShoppingCart.aspx");
        }
Example #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["productID"];
            int    productID;

            if (!string.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productID))
            {
                using (ShoppingCartActions userShoppingCart = new ShoppingCartActions())
                {
                    userShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            else
            {
                Debug.Fail("ERROR");
            }
            Response.Redirect("ShoppingCart.aspx");
        }
Example #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out int productId))
            {
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            else
            {
                Debug.Fail("BŁĄD : Nie można odnaleść ID produktu.");
                throw new Exception("BŁĄD : Bez ID produktu nie możemy zakończyć.");
            }
            Response.Redirect("ShoppingCart.aspx");
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        string rawId = Request["ProductID"];
        int    productId;

        if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
        {
            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
            {
                usersShoppingCart.AddToCart(productId);
            }
        }
        else
        {
            throw new Exception("Tried to call AddToCart.aspx without setting a ProductId.");
        }
        Response.Redirect("ShoppingCart.aspx");
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawProductID = Request.QueryString["ProductID"];
            int    productID;

            Int32.TryParse(rawProductID, out productID);

            if (!string.IsNullOrEmpty(rawProductID) && Int32.TryParse(rawProductID, out productID))
            {
                ShoppingCartActions userShoppingCart = new ShoppingCartActions();

                userShoppingCart.AddToCart(productID);
            }
            else
            {
                throw new Exception("Error loading page without ID");
            }
            Response.Redirect("ShoppingCart.aspx");
        }
        public ActionResult AddToCart()
        {
            string rawId = Request.QueryString["ProductId"];
            int    productId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            else
            {
                Debug.Fail("ERROR : We should never get to /ShoppingCart/AddToCart without a ProductId.");
                throw new Exception("ERROR : It is illegal to load /ShoppingCart/AddToCart without setting a ProductId.");
            }
            return(RedirectToAction("Index"));
        }
Example #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];
            int    productId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            else
            {
                Debug.Fail("ERROR : Nigdy nie powinniśmy dostać się do AddToCart.aspx bez ProductId.");
                throw new Exception("ERROR : Nie da się załadować AddToCart.aspx bez ustawienia ProductId.");
            }
            Response.Redirect("ShoppingCart.aspx");
        }
Example #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["productID"];
            int    productId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            else
            {
                Debug.Fail("Error: Nema productID");
                throw new Exception("Error: Nema productID");
            }
            Response.Redirect("Kosarica.aspx");
        }
Example #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["SportID"];
            int    SportId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out SportId))
            {
                using (ShoppingCartActions usersShoppingCart = new
                                                               ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            else
            {
                Debug.Fail("loi, xin thu lai");
                throw new Exception("He thong loi, vui long thu lai !!.");
            }
            Response.Redirect("ShoppingCart.aspx");
        }
Example #23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IList <string> segments = Request.GetFriendlyUrlSegments();
            string         rawId    = segments[0];
            int            productId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            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("~/Checkout/ShoppingCart.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //string rawId = Request.QueryString["ProductID"];
            string rawId = Request.QueryString["idLivro"];
            int    livroId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out livroId))
            {
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            else
            {
                Debug.Fail("ERROR : Nunca devemos chegar ao AddToCart.aspx sem um idLivro.");
                throw new Exception("ERROR : É ilegal carregar o AddToCart.aspx sem definir um idLivro.");
            }
            Response.Redirect("ShoppingCart.aspx");
        }
Example #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];
            int    productId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                // instantiate a new shopping cart logic object to call AddToCart() based on product ID
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            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.");
            }
            // Show user updated cart, this page is just a logic page and should never be seen by the user.
            Response.Redirect("ShoppingCart.aspx");
        }
Example #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];

            int productId;

            if (!string.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                using (var shoppingCartActions = new ShoppingCartActions())
                {
                    shoppingCartActions.AddToCart(Convert.ToInt16(rawId));
                }
            }
            else
            {
                Debug.Fail("ERROR: AddToCart MUST NOT be called without a productId");

                throw new Exception("AddToCart MUST NOT be called without a Product ID");
            }
            Response.Redirect("ShoppingCart.aspx");
        }
        /**When user clicks "add to cart", send product id, product name, and unit price to shopping cart action file to create 'added' event in Cosmos DB**/
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];
            int    productId;
            string productName = Request.QueryString["ProductName"];
            string unitPrice   = Request.QueryString["UnitPrice"];

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId), productName, Convert.ToDouble(unitPrice));
                }
            }
            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.");
            }
            /**Redirect user to view their shopping cart**/
            Response.Redirect("ShoppingCart.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];             //дістаємо айді продукту і присвоюємо у змінну
            int    productId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    //визиває метод AddToCart коли створено екземпляр корзини
                    //після добавлення продукту у корзину, ця стрінка перенаправляє до ShoppingCart.aspx,
                    //з оновленою інфою
                    usersShoppingCart.AddToCart(productId);
                }
            }

            else
            {
                Debug.Fail("error не можна переходити на сторінку AddToCart без ProductId");
                throw new Exception("error");
            }
            Response.Redirect("ShoppingCart.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProductID"];
            int    productId;

            //provera da li je string prazan - ako nije i ako je productId int
            // TryParse pokusava od zadatog stringa da napravi int sto upisuje u productId  int.TryParse(rawId, out productId)
            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                //instanciramo klasu ShoppingCartActions koja ima u sebi deklarisanu metodu AddToCart
                using (ShoppingCartActions userShoppingCart = new ShoppingCartActions())
                {
                    userShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            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.");
                //Nikada nećemo stići do AddToCart.aspk bez ProductId-a
                //Nije dopušteno učitavanje AddToCart.aspk bez postavljanja ProductId-a
            }
            Response.Redirect("ShoppingCart.aspx");
        }
Example #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            /* When the page is loaded the product ID is retieved from the query string.
             * Then an instance of the shopping cart is created and used to call the AddToCart Method. */

            string rawId = Request.QueryString["ProductID"];
            int    productId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out productId))
            {
                using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
                {
                    usersShoppingCart.AddToCart(Convert.ToInt16(rawId));
                }
            }
            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.");
            }

            //Redirects to the shopping cart where the user can see an updated list of items in the cart.
            Response.Redirect("ShoppingCart.aspx");
        }