Пример #1
0
        public ActionResult SanPhamMoiVeInChiTiet()
        {
            IList <ProductFrontPageMapping.ProductBox>     products   = _menuRepository.GetProductNew(5);
            IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives();

            PromotionMapping.GetPromotion(promotions, products);
            SanPhamMoiVeModel model = new SanPhamMoiVeModel()
            {
                Products = products,
            };

            return(View("SanPhamMoiVe", model));
        }
        public ActionResult SanPhamDaXemDetail()
        {
            IList <int>  productIds   = new List <int>();
            CookieHelper cookieHelper = new CookieHelper("product_watched");

            if (cookieHelper.GetCookie() != null)
            {
                string json = HttpUtility.UrlDecode(cookieHelper.GetCookie().Values["product_watched"]);
                if (!string.IsNullOrEmpty(json))
                {
                    productIds = json.Split(',').Select(o => Convert.ToInt32(o)).ToList();
                }
            }

            IList <ProductFrontPageMapping.ProductBox> products = new List <ProductFrontPageMapping.ProductBox>();

            if (productIds.Any())
            {
                var allMenus = _menuRepository.GetAllMenuCache();
                products = (from m in allMenus
                            where productIds.Contains(m.id_) && m.idControl == 11 && m.ok && m.HasValue
                            select new ProductFrontPageMapping.ProductBox
                {
                    id_ = m.id_,
                    Img = m.Img,
                    NameProduct =
                        m.NameProduct,
                    PricePro = m.PricePro,
                    Link = m.Link,
                    HasOnHand = m.HasOnHand,
                    NgayHetHang = m.NgayHetHang
                }).Take(10).ToList();
            }

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

            PromotionMapping.GetPromotion(promotions, products);

            SanPhamMoiVeModel model = new SanPhamMoiVeModel()
            {
                Products = products
            };

            return(View("SanPhamDaXemDetail", model));
        }