public ActionResult GoodsComment(int num, int goodsid) { List <CommentTable> list = CommentBll.SelectGoodsComment(goodsid); //好评 if (num == 0) { list = list.Where(p => p.CommentStarRating >= 4).ToList(); } else if (num == 1) { //中评 list = list.Where(p => p.CommentStarRating == 3).ToList(); } else if (num == 2) { //差评 list = list.Where(p => p.CommentStarRating <= 2).ToList(); } ViewBag.num = num; Session["GoodsComment"] = list; return(PartialView("GoodsComment")); }
/// <summary> /// 商品详情 /// </summary> /// <param name="goodsid">商品id</param> /// <returns></returns> public ActionResult GoodsDesc(int goodsid) { //商品图片 ViewBag.GoodsPhoto = GoodsPhotoBll.SelectAllGoodsPhoto().Where(p => p.GoodsID == goodsid).ToList(); //商品的所有评价(置顶排序) List <CommentTable> list = CommentBll.SelectGoodsComment(goodsid).OrderByDescending(p => p.IsTop).ToList(); Session["GoodsComment"] = list; //用户是否收藏商品 ViewBag.iscollection = CollectionBll.SelectOneCollection(Convert.ToInt32(Session["userid"]), goodsid); //加载或更新用户购物车数量 if (Session["userid"] != null) { Session["carcount"] = ShopingCarBll.SelectAllShopCar(Convert.ToInt32(Session["userid"])).Count(); } //获取到的该商品的信息 GoodsTable good = GoodsBll.SelectGoodsIdGoods(goodsid); //相关商品的推荐(3条) ViewBag.GetGoods = GoodsBll.SelectGetGoods(good.TID ?? 0).Where(p => p.GoodsID != good.GoodsID).OrderBy(p => Guid.NewGuid()).Take(3).ToList(); Session["GoodsPhoto"] = GoodsPhotoBll.SelectAllGoodsPhoto(); return(View(good)); }