Exemple #1
0
        public ActionResult Vegetables(Product inputData)
        {
            if (inputData.ProductQuantity > 0)
            {
                if (ShoppingCartCheck.CheckIfExistInDB(inputData.ProductName, inputData.ProductPrice, inputData.ProductQuantity, 0) == false)
                {
                }
            }
            var data = ProductProccessor.LoadProduct("dbo.Vegetables", "NatureBoxDB");

            List <Product> products = new List <Product>();

            foreach (var product in data)
            {
                products.Add(new Product
                {
                    ProductName     = product.ProductName,
                    ProductPrice    = product.ProductPrice,
                    ProductBenefits = product.ProductBenefits,
                    ProductAbout    = product.ProductAbout,
                    ProductImage    = product.ProductImage,
                    ProductQuantity = 0
                });
            }

            return(View(products));
        }
Exemple #2
0
        private List <ShoppingCart> makeListOfProducts()
        {
            var data = ShoppingCartCheck.LoadProductSC("dbo.ShoppingCart", "NatureBoxDB");
            List <ShoppingCart> products = new List <ShoppingCart>();

            foreach (var product in data)
            {
                var prod = new ShoppingCart()
                {
                    ProductName     = product.ProductName,
                    ProductPrice    = product.ProductPrice,
                    ProductQuantity = product.ProductQuantity,
                    TotalPrice      = product.ProductQuantity * product.ProductPrice,
                };
                if (product.ProductType == 1)
                {
                    prod.ProductType = true;
                }
                else
                {
                    prod.ProductType = false;
                }

                products.Add(prod);
            }
            return(products);
        }
Exemple #3
0
 public ActionResult BuyAll()
 {
     ShoppingCartCheck.DeleteAll("NatureBoxDB", "ShoppingCart");
     return(View("ShoppingCart", makeListOfProducts()));
 }
Exemple #4
0
 public ActionResult Delete(ShoppingCart data)
 {
     ShoppingCartCheck.DeleteProduct("NatureBoxDB", "dbo.ShoppingCart", data.ProductName);
     Session["productsInCart"] = Convert.ToInt32(Session["productsInCart"]);
     return(RedirectToAction("ShoppingCart", makeListOfProducts()));
 }