コード例 #1
0
        // GET: Admin
        public ActionResult Index()
        {
            Product_Bll bll    = new Product_Bll();
            var         result = bll.GetAllProducts();

            return(View(result));
        }
コード例 #2
0
        public ActionResult AddToCart(int id)
        {
            Product_Bll bll = new Product_Bll();

            if (Session["CurrentUser"] != null)
            {
                if (Session["cart"] == null)
                {
                    List <ItemCart> list = new List <ItemCart>();
                    list.Add(new ItemCart {
                        Product = bll.GetProductById(id), Quantity = 1
                    });
                    Session["cart"] = list;
                }
                else
                {
                    List <ItemCart> list  = Session["cart"] as List <ItemCart>;
                    int             index = isExist(id);
                    if (index != -1)
                    {
                        list[index].Quantity++;
                    }
                    else
                    {
                        list.Add(new ItemCart {
                            Product = bll.GetProductById(id), Quantity = 1
                        });
                    }
                    Session["cart"] = list;
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public ActionResult GetProductById(int id)
        {
            Product_Bll bll    = new Product_Bll();
            var         result = bll.GetAllProducts().Where(s => s.Category_Id == id);

            return(PartialView(result));
        }
コード例 #4
0
        public ActionResult GetAllProduct()
        {
            Product_Bll bll    = new Product_Bll();
            var         result = bll.GetAllProducts();

            return(PartialView(result));
        }
コード例 #5
0
        // GET: Product
        public ActionResult Index()
        {
            TempData["editUser"]       = string.Empty;
            TempData["ChangePassword"] = string.Empty;
            TempData["Contact"]        = string.Empty;
            Product_Bll bll    = new Product_Bll();
            var         result = bll.GetAllProducts();

            return(View(result));
        }
コード例 #6
0
        public ActionResult EditProduct(int id)
        {
            Product_Bll product_Bll = new Product_Bll();

            var          result       = product_Bll.GetProductById(id);
            Category_Bll category_Bll = new Category_Bll();
            var          categoryList = category_Bll.GetAllCategories();
            SelectList   items        = new SelectList(categoryList, "Id", "Name");

            ViewBag.category = items;
            return(PartialView(result));
        }
コード例 #7
0
        public ActionResult AddProduct(Product product, HttpPostedFileBase ImagePath)
        {
            Product_Bll product_Bll = new Product_Bll();

            if (ImagePath != null)
            {
                ImagePath.SaveAs(Server.MapPath("~/images/" + ImagePath.FileName));
                product.Image = "~/images/" + ImagePath.FileName;
            }
            else
            {
                product.Image = "~/images/item-cart-01.jpg";
            }
            product_Bll.AddProduct(product);

            return(RedirectToAction("Index"));
        }
コード例 #8
0
        public ActionResult Index()
        {
            TempData["Contact"]        = string.Empty;
            ViewBag.order              = TempData["order"];
            ViewBag.errorLogin         = TempData["LoginError"];
            ViewBag.register           = TempData["rigster"];
            ViewBag.profile            = TempData["profile"];
            TempData["editUser"]       = string.Empty;
            TempData["ChangePassword"] = string.Empty;
            Product_Bll  bll          = new Product_Bll();
            var          result       = bll.GetAllProducts();
            Category_Bll category_bll = new Category_Bll();
            var          categoryList = category_bll.GetAllCategories();

            ViewBag.categoryList = categoryList;
            return(View(result));
        }
コード例 #9
0
        public ActionResult EditProduct(Product product, HttpPostedFileBase ImagePath)
        {
            Product_Bll product_Bll = new Product_Bll();
            Product     oldproduct  = product_Bll.GetProductById(product.Id);

            if (ImagePath != null)
            {
                ImagePath.SaveAs(Server.MapPath("~/images/" + ImagePath.FileName));
                product.Image = "~/images/" + ImagePath.FileName;
            }
            else
            {
                product.Image = oldproduct.Image;
            }
            product_Bll.EditProduct(product);

            return(RedirectToAction("Index"));
        }