Example #1
0
        // GET: Shop
        //=================================商城首頁===============================================
        public ActionResult Index(int id = 0)
        {
            ShopUse shopuse = new ShopUse();

            shopuse.categories = categories.GetAll();
            if (id == 0)
            {
                TempData["change"] = 0;
                if (Session["shopping_car"] != null)
                {
                    shopuse.shopping_car = Session["shopping_car"] as List <int>;
                }
                shopuse.products = products.GetAll();
                return(View(shopuse));
            }
            else
            {
                TempData["change"] = id;
                if (Session["shopping_car"] != null)
                {
                    shopuse.shopping_car = Session["shopping_car"] as List <int>;
                }
                shopuse.products = products.GetAll().Where(p => p.CategoryID == id).Select(p => p);
                return(View(shopuse));
            }
        }
Example #2
0
 //=========================================購物車結帳頁面=========================================
 public ActionResult Accounting(int id = 0)
 {
     if (id == 0)
     {
         ShopUse shopuse = new ShopUse();
         shopuse.shopping_car = Session["shopping_car"] as List <int>;
         if (Session["shopping_car"] != null)
         {
             shopuse.products = shopuse.product_account(Session["shopping_car"] as List <int>);
         }
         return(View(shopuse));
     }
     else
     {
         Session["shopping_car"] = null;
         return(RedirectToAction("Index", "Shop", null));
     }
 }