public ActionResult Index(int pageSize = 10, int pageNo = 1) { PageModel <FavoriteShopInfo> userConcernShops = ServiceHelper.Create <IShopService>().GetUserConcernShops(base.CurrentUser.Id, pageNo, pageSize); List <ShopConcernModel> shopConcernModels = new List <ShopConcernModel>(); foreach (FavoriteShopInfo list in userConcernShops.Models.ToList()) { if (list.Himall_Shops == null) { continue; } ShopConcernModel shopConcernModel = new ShopConcernModel(); shopConcernModel.FavoriteShopInfo.Id = list.Id; shopConcernModel.FavoriteShopInfo.Logo = list.Himall_Shops.Logo; shopConcernModel.FavoriteShopInfo.ConcernTime = list.Date; shopConcernModel.FavoriteShopInfo.ShopId = list.ShopId; shopConcernModel.FavoriteShopInfo.ShopName = list.Himall_Shops.ShopName; shopConcernModel.FavoriteShopInfo.ConcernCount = list.Himall_Shops.Himall_FavoriteShops.Count(); IQueryable <ProductInfo> hotSaleProduct = ServiceHelper.Create <IProductService>().GetHotSaleProduct(list.ShopId, 10); if (hotSaleProduct != null) { foreach (ProductInfo productInfo in hotSaleProduct) { List <HotProductInfo> hotSaleProducts = shopConcernModel.HotSaleProducts; HotProductInfo hotProductInfo = new HotProductInfo() { ImgPath = productInfo.ImagePath, Name = productInfo.ProductName, Price = productInfo.MinSalePrice, Id = productInfo.Id, SaleCount = (int)productInfo.SaleCounts }; hotSaleProducts.Add(hotProductInfo); } } IQueryable <ProductInfo> newSaleProduct = ServiceHelper.Create <IProductService>().GetNewSaleProduct(list.ShopId, 10); if (newSaleProduct != null) { foreach (ProductInfo productInfo1 in newSaleProduct) { List <HotProductInfo> newSaleProducts = shopConcernModel.NewSaleProducts; HotProductInfo hotProductInfo1 = new HotProductInfo() { ImgPath = productInfo1.ImagePath, Name = productInfo1.ProductName, Price = productInfo1.MinSalePrice, Id = productInfo1.Id, SaleCount = productInfo1.ConcernedCount }; newSaleProducts.Add(hotProductInfo1); } } shopConcernModels.Add(shopConcernModel); } PagingInfo pagingInfo = new PagingInfo() { CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = userConcernShops.Total }; ViewBag.pageInfo = pagingInfo; return(View(shopConcernModels)); }
// GET: Web/ProductConcern public ActionResult Index(int pageSize = 10, int pageNo = 1) { var model = _iShopService.GetUserConcernShops(CurrentUser.Id, pageNo, pageSize); List <ShopConcernModel> list = new List <Models.ShopConcernModel>(); foreach (var m in model.Models.ToList()) { if (null != m.Himall_Shops) { ShopConcernModel concern = new ShopConcernModel(); concern.FavoriteShopInfo.Id = m.Id; concern.FavoriteShopInfo.Logo = m.Himall_Shops.Logo; concern.FavoriteShopInfo.ConcernTime = m.Date; concern.FavoriteShopInfo.ShopId = m.ShopId; concern.FavoriteShopInfo.ShopName = m.Himall_Shops.ShopName; concern.FavoriteShopInfo.ConcernCount = m.Himall_Shops.Himall_FavoriteShops.Count(); #region 热门使用 var sale = _iProductService.GetHotSaleProduct(m.ShopId, 10); if (sale != null) { foreach (var item in sale) { concern.HotSaleProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.SaleCounts }); } } #endregion #region 最新上架 var newsale = _iProductService.GetNewSaleProduct(m.ShopId, 10); if (newsale != null) { foreach (var item in newsale) { concern.NewSaleProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.ConcernedCount }); } } list.Add(concern); #endregion } } PagingInfo info = new PagingInfo { CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = model.Total }; ViewBag.pageInfo = info; return(View(list)); }
public ActionResult Index(int pageSize = 10, int pageNo = 1) { var model = _iShopService.GetUserConcernShops(CurrentUser.Id, pageNo, pageSize); var list = new List <ShopConcernModel>(); foreach (var m in model.Models) { var shop = ShopApplication.GetShop(m.ShopId); if (shop == null) { continue; } ShopConcernModel concern = new ShopConcernModel(); concern.FavoriteShopInfo.Id = m.Id; concern.FavoriteShopInfo.Logo = shop.Logo; concern.FavoriteShopInfo.ConcernTime = m.Date; concern.FavoriteShopInfo.ShopId = m.ShopId; concern.FavoriteShopInfo.ShopName = shop.ShopName; concern.FavoriteShopInfo.ConcernCount = FavoriteApplication.GetFavoriteShopCountByShop(m.ShopId); concern.FavoriteShopInfo.ShopStatus = shop.ShopStatus; #region 热门销售 var sale = _iProductService.GetHotSaleProduct(m.ShopId, 10); if (sale != null) { foreach (var item in sale) { concern.HotSaleProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)(item.SaleCounts + item.VirtualSaleCounts) }); } } #endregion #region 最新上架 var newsale = _iProductService.GetNewSaleProduct(m.ShopId, 10); if (newsale != null && newsale.Count > 0) { foreach (var item in newsale) { concern.NewSaleProducts.Add(new HotProductInfo { ImgPath = item.ImagePath, Name = item.ProductName, Price = item.MinSalePrice, Id = item.Id, SaleCount = (int)item.ConcernedCount }); } } list.Add(concern); #endregion } PagingInfo info = new PagingInfo { CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = model.Total }; ViewBag.pageInfo = info; ViewBag.Keyword = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword; ViewBag.Keywords = SiteSettings.HotKeyWords; return(View(list)); }