// GET: Goods public ActionResult GoodsIndex(int?tid_1, int?typeid_1, int?typeid_2, string txt = "") { //清空session数据 Session.Remove("Goods"); Session.Remove("Goods_tid"); Session.Remove("Goods_typeid"); //获得所有分类数据 ViewBag.Type = TypeTableBll.SelectAllType(); ViewBag.GoodsPhoto = GoodsPhotoBll.SelectAllGoodsPhoto(); if (tid_1 != null) { //根据tid查询 Session["Goods_tid"] = GoodsBll.SelectTidGoods(tid_1 ?? 0); //ViewBag.tid = tid_1 ?? 0; } else if (typeid_1 != null) { //根据tiyeid查询 Session["Goods_typeid"] = GoodsBll.SelectTypeidGoods(typeid_1 ?? 0); } else if (typeid_2 != null) { Session["Goods_typeid_2"] = GoodsBll.SelectType1Goods(typeid_2 ?? 0); } else { Session["Goods"] = GoodsBll.SelectAllGoods().Where(p => p.GoodsName.Contains(txt) && p.IsDelte == 0).OrderBy(p => p.GoodsHot).ToList(); } return(View()); }
/// <summary> /// 商城首页 /// </summary> /// <returns></returns> public ActionResult Index() { //获取导航栏的分类数据 Session["Type"] = TypeTableBll.SelectTypeTable(); //获得所有分类数据 ViewBag.Type = TypeTableBll.SelectAllType(); //获取图片 ViewBag.GoodsPhoto = GoodsPhotoBll.SelectAllGoodsPhoto(); ViewBag.goods_1 = GoodsBll.SelectType1Goods(1).OrderBy(p => p.GoodsHot).Take(8); ViewBag.goods_2 = GoodsBll.SelectType1Goods(2).OrderBy(p => p.GoodsHot).Take(8); ViewBag.goods_3 = GoodsBll.SelectType1Goods(3).OrderBy(p => p.GoodsHot).Take(8); ViewBag.goods_4 = GoodsBll.SelectType1Goods(4).OrderBy(p => p.GoodsHot).Take(8); if (Session["userid"] != null) { Session["carcount"] = ShopingCarBll.SelectAllShopCar(Convert.ToInt32(Session["userid"])).Count(); } return(View(GoodsBll.SelectAllGoods().Where(p => p.IsDelte == 0).ToList())); }