public ActionResult DanhSach(int?page, string linkth)
        {
            int          pageNumber = (page ?? 1);
            int          id         = _menuRepository.GetidDanhMucByLink(linkth);
            IList <Menu> sanPhams   =
                _menuRepository.getSanPhamThuocThuongHieu(linkth).OrderByDescending(o => o.sDate).OrderBy(o => o.SapXepSanPham).Where(o => o.ok && o.HasValue).ToList();
            IList <ProductFrontPageMapping.ProductBox> sanPhamsCuaDanhMuc = new List <ProductFrontPageMapping.ProductBox>();

            //lay duong dan cua san pham
            ViewData["duongdancha"] = _menuRepository.GetTenDanhMucCha(linkth);
            ViewData["duongdancon"] = _menuRepository.GetTenDanhMuc(linkth);
            IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives();

            foreach (var sanpham in sanPhams)
            {
                ProductFrontPageMapping.ProductBox sp = new ProductFrontPageMapping.ProductBox()
                {
                    Img         = sanpham.Img,
                    NameProduct = sanpham.NameProduct,
                    PricePro    = sanpham.PricePro,
                    id_         = sanpham.id_,
                    Link        = sanpham.Link,
                    HasOnHand   = sanpham.HasOnHand,
                    NgayHetHang = sanpham.NgayHetHang
                };
                #region check promotion
                if (promotions.Any())
                {
                    foreach (var pr in promotions)
                    {
                        var promotionDetail = pr.PromotionDetails.FirstOrDefault(dt => dt.ProductId == sp.id_);
                        if (promotionDetail != null)
                        {
                            sp.HasPromotion   = true;
                            sp.PricePromotion = (int)promotionDetail.PriceDiscount;
                            sp.Discount       = (short)promotionDetail.Percent;
                            break;
                        }
                    }
                }

                #endregion
                sanPhamsCuaDanhMuc.Add(sp);
            }
            DanhSach model = new DanhSach()
            {
                DanhMuc             = _menuRepository.GetById(id),
                SanPhamTheoDanhMucs = sanPhamsCuaDanhMuc.ToPagedList(pageNumber, pageSize),
            };
            return(View(model));
        }
        public ActionResult DanhSach100BanChay(int?page)
        {
            int          pageNumber = (page ?? 1);
            IList <Menu> sanPhams   = _menuRepository.GetMany(o => o.Bestseller && o.ok && o.HasOnHand && o.HasValue)
                                      .ToList();
            IList <ProductFrontPageMapping.ProductBox> sanPhamsCuaDanhMuc = new List <ProductFrontPageMapping.ProductBox>();

            IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives();

            foreach (var sanpham in sanPhams)
            {
                ProductFrontPageMapping.ProductBox sp = new ProductFrontPageMapping.ProductBox()
                {
                    Img         = sanpham.Img,
                    NameProduct = sanpham.NameProduct,
                    PricePro    = sanpham.PricePro,
                    id_         = sanpham.id_,
                    Link        = sanpham.Link,
                    HasOnHand   = sanpham.HasOnHand,
                    NgayHetHang = sanpham.NgayHetHang
                };
                #region check promotion
                if (promotions.Any())
                {
                    foreach (var pr in promotions)
                    {
                        var promotionDetail = pr.PromotionDetails.FirstOrDefault(dt => dt.ProductId == sp.id_);
                        if (promotionDetail != null)
                        {
                            sp.HasPromotion   = true;
                            sp.PricePromotion = (int)promotionDetail.PriceDiscount;
                            sp.Discount       = (short)promotionDetail.Percent;
                            break;
                        }
                    }
                }

                #endregion
                sanPhamsCuaDanhMuc.Add(sp);
            }
            DanhSach model = new DanhSach()
            {
                SanPhamTheoDanhMucs = sanPhamsCuaDanhMuc.ToPagedList(pageNumber, pageSize),
            };
            return(View("DanhSach100BanChay", model));
        }