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 SanPhamCoQuaTang() { IList <ProductFrontPageMapping.ProductBox> products = _menuRepository.GetProductQuaTang(); IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives(); PromotionMapping.GetPromotion(promotions, products); QuaTangModel model = new QuaTangModel() { Products = products }; return(View("SanPhamCoQuaTang", model)); }
public ActionResult QuaTangInDetail(int productId) { var idquatang = _khoQuaTangRepository.Get(o => o.IdMenu == productId).IdSanPhamTang; IList <ProductFrontPageMapping.ProductBox> products = _menuRepository.GetProductQuaTangByproductId(int.Parse(idquatang)); IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives(); PromotionMapping.GetPromotion(promotions, products); QuaTangModel model = new QuaTangModel() { Products = products }; return(View("quatangindetail", model)); }
public ActionResult Index(int?page) { int pageNumber = (page ?? 1); IList <ProductFrontPageMapping.ProductBox> products = _menuRepository.GetProductQuaTang(); IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives(); PromotionMapping.GetPromotion(promotions, products); KhoQuaTangModel model = new KhoQuaTangModel() { Products = products.ToPagedList(pageNumber, pageSize) }; return(View("Index", model)); }
/// <summary> /// Danh sách tag cho sản phẩm /// </summary> /// <param name="tentag"></param> /// <returns></returns> public ActionResult DanhSach(string tentag) { ViewData["tentag"] = tentag.Replace("-", " "); IList <ProductFrontPageMapping.ProductBox> products = _menuRepository.LayTatCaSanphamTheoTag(tentag.Replace("-", " ")); IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives(); PromotionMapping.GetPromotion(promotions, products); DanhSach model = new DanhSach() { SanPhamTheoTags = products, DanhSachTag = _danhSachTagRepository.GetSeoTag(tentag.Replace("-", " ")) }; return(View("DanhSach", model)); }
public ActionResult ShowDataBestSeller(int iddanhmuc) { var allMenus = _menuRepository.GetAllMenuCache(); var ids = new List <int>() { iddanhmuc }; var childsDm = allMenus.Where(o => o.Style == "danh-muc-san-pham" && o.idControl == iddanhmuc); ids.AddRange(childsDm.Select(o => o.id_)); IList <ProductFrontPageMapping.ProductShow> dataProduct = _menuRepository.LaySanPhamCuaListDanhMucTrangChu(ids); IList <ProductFrontPageMapping.CategoryBoxHome> model = new List <ProductFrontPageMapping.CategoryBoxHome>(); IList <ProductFrontPageMapping.CategoryBoxHomeChild> childItems = new List <ProductFrontPageMapping.CategoryBoxHomeChild>(); IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives(); dataProduct = PromotionMapping.GetPromotionProductShow(promotions, dataProduct); childItems.Add(new ProductFrontPageMapping.CategoryBoxHomeChild() { Id = 0, Link = "", Name = "", Products = dataProduct, }); model.Add(new ProductFrontPageMapping.CategoryBoxHome() { Id = 0, Link = "", Name = "", Icon = "", Childs = childItems }); SanPhamViewModel.ProductBoxViewmodel data = new SanPhamViewModel.ProductBoxViewmodel() { Categories = model, }; return(PartialView("ProductBoxChild", data)); }
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)); }
public ActionResult Index(int?page) { int pageNumber = (page ?? 1); 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(9).ToList(); } IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives(); PromotionMapping.GetPromotion(promotions, products); DanhSach model = new DanhSach() { SanPhamTheoDanhMucs = products.ToPagedList(pageNumber, pageSize), }; return(View("DanhSach", model)); }
public ActionResult Index() { var allMenus = _menuRepository.GetAllMenuCache(); //Lấy tất cả danh mục ông nội IList <ProductFrontPageMapping.CategoryBoxHomeLv1> categorysAll = allMenus.Any() ? (from d in allMenus.Where( o => o.Style == "danh-muc-san-pham" && o.idControl != 0) select new ProductFrontPageMapping. CategoryBoxHomeLv1 { id_ = d.id_, CategoryName = d.NameProduct, idControl = d.idControl, LevelMenu = d.LevelMenu, Link = d.Link, IconMenu = d.IconMenu, ShowMenuHome = d.ShowMenuHome, SapxepDanhMuc = d.SapxepDanhMuc, ok = d.ok }).ToList() : new List < ProductFrontPageMapping. CategoryBoxHomeLv1>(); // trang điểm, chăm sóc da IList <ProductFrontPageMapping.CategoryBoxHomeLv1> Menulevel1 = categorysAll.Where(p => p.ok && p.LevelMenu == 1 && p.idControl == 1 && p.id_ != 3351).OrderBy(p => p.SapxepDanhMuc).ToList(); IList <ProductFrontPageMapping.CategoryBoxHomeChild> childItems = new List <ProductFrontPageMapping.CategoryBoxHomeChild>(); if (Menulevel1.Any()) { foreach (var boxHomeLv1 in Menulevel1) { IList <ProductFrontPageMapping.ProductShow> dataProduct = new List <ProductFrontPageMapping.ProductShow>(); childItems.Add(new ProductFrontPageMapping.CategoryBoxHomeChild() { Id = boxHomeLv1.id_, Link = boxHomeLv1.Link, Name = boxHomeLv1.CategoryName, Products = dataProduct }); } } IList <ProductFrontPageMapping.ProductBox> products = _menuRepository.GetProductBestsellerShowHome(); IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives(); PromotionMapping.GetPromotion(promotions, products); SanPhamViewModel.TopSeller model = new SanPhamViewModel.TopSeller() { MenuAndProducts = childItems, Products = products }; return(View("BestSeller", model)); }
public ActionResult DanhSach(int id, string sortOrder, string currentFilter, int page = 1) { int pageNumber = page; var allMenus = _menuRepository.GetAllMenuCache().Where(o => o.Style == "danh-muc-san-pham").ToList(); IList <ProductFrontPageMapping.ProductBox> products = new List <ProductFrontPageMapping.ProductBox>(); Menu danhMuc = allMenus.FirstOrDefault(o => o.id_.Equals(id)); using (var context = new ShopDataContex()) { SqlParameter idanhmuc = new SqlParameter("idanhmuc", danhMuc.id_); products = context.Database.SqlQuery <ProductFrontPageMapping.ProductBox>("exec Product_Top100Tuan @idanhmuc", idanhmuc).ToList(); } ViewBag.CurrentSort = sortOrder; ViewBag.TuannaySort = sortOrder == "tuannay" ? "tuannay" : "tuannay"; ViewBag.ThangnaySort = sortOrder == "thangnay" ? "thangnay" : "thangnay"; ViewBag.Best2016Sort = sortOrder == "Best2016" ? "Best2016" : "Best2016"; switch (sortOrder) { case "tuannay": IList <ProductFrontPageMapping.ProductBox> productOrderTheoTuans = new List <ProductFrontPageMapping.ProductBox>(); using (var context = new ShopDataContex()) { SqlParameter idanhmuc = new SqlParameter("idanhmuc", danhMuc.id_); productOrderTheoTuans = context.Database.SqlQuery <ProductFrontPageMapping.ProductBox>("exec Product_Top100Tuan @idanhmuc", idanhmuc).ToList(); } products = productOrderTheoTuans.Take(100).ToList(); // trong tuan break; case "thangnay": IList <ProductFrontPageMapping.ProductBox> productOrderTheoThangs = new List <ProductFrontPageMapping.ProductBox>(); using (var context = new ShopDataContex()) { SqlParameter idanhmuc = new SqlParameter("idanhmuc", danhMuc.id_); productOrderTheoThangs = context.Database.SqlQuery <ProductFrontPageMapping.ProductBox>("exec Product_Top100Thang @idanhmuc", idanhmuc).ToList(); } products = productOrderTheoThangs.Take(100).ToList(); // trong thang break; case "Best2016": IList <ProductFrontPageMapping.ProductBox> productOrderBest2016 = new List <ProductFrontPageMapping.ProductBox>(); using (var context = new ShopDataContex()) { SqlParameter idanhmuc = new SqlParameter("idanhmuc", danhMuc.id_); productOrderBest2016 = context.Database.SqlQuery <ProductFrontPageMapping.ProductBox>("exec Product_Best2016 @idanhmuc", idanhmuc).ToList(); } products = productOrderBest2016.Take(100).ToList(); // trong nam 2016 break; default: products = products.Take(100).ToList(); // trong tuan break; } IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives(); products = PromotionMapping.GetPromotion(promotions, products); DanhSachBestSeller model = new DanhSachBestSeller() { DanhMuc = danhMuc, SanPhamTheoDanhMucs = products.ToPagedList(pageNumber, pageSize), page = page }; return(View("DanhSach", model)); }
public ActionResult Index() { //danh sach san pham xem cung duoc code theo thuat toan //step 1: lay cookie cua san pham da xem chay for tach ra tung id va luu vao db //chu y: lan xem dau tien khong xay ra su kien gi: tuc la khong luu vao db hay update IList <int> productIds = new List <int>(); IList <int> DanhsachSpGoiY = new List <int>(); IList <ProductFrontPageMapping.ProductBox> products = new List <ProductFrontPageMapping.ProductBox>(); CookieHelper cookieHelper = new CookieHelper("product_xemcung"); if (cookieHelper.GetCookie() != null) { string json = HttpUtility.UrlDecode(cookieHelper.GetCookie().Values["product_xemcung"]); if (!string.IsNullOrEmpty(json)) { productIds = json.Split(',').Select(o => Convert.ToInt32(o)).ToList(); } } if (productIds.Any() && productIds.Count >= 2) { int idsp = 0, idsptiep = 0; //san pham xem dau tien khong xu ly, bat dau xu ly tu san pham thu 2 for (int i = 0; i < productIds.Count; i++) { idsp = productIds[productIds.Count - 2]; idsptiep = productIds[productIds.Count - 1]; } SanPhamXemCung sanPham = new SanPhamXemCung() { IdSanPham = idsp, IdSanPhamTiepTheo = idsptiep, SoLanXem = 1 }; //kiem tra neu nhu idsp cua dong nay = idsp cua dong kia, idsptiep cua dong nay bang idsptiep cua dong kia //==> thi update so lan xem len chứ không lưu SanPhamXemCung dataXemCung = _phamXemCungRepository.Getdatatrung(idsp, idsptiep); int sltrung = _phamXemCungRepository.GetslTrung(idsp, idsptiep); if (sltrung != 0) { //neu trung thi update dong do len using (var context = new ShopDataContex()) { context.Database.ExecuteSqlCommand("update SanPhamXemCungs set SoLanXem=SoLanXem+1 where SanPhamXemCungId={0}", dataXemCung.SanPhamXemCungId); } } else { //them moi _phamXemCungRepository.Add(sanPham); _unitOfWork.Commit(); } //lay danh sach id cua idsanpham va idsanphamtieptheo kiem tra voi thang idsptiep khi nguoi dung xem //neu id duoi DB co chua thang nguoi dung xem thi lay danh sach id theo thuat toan DanhsachSpGoiY = _phamXemCungRepository.danhsachIds(idsptiep); if (DanhsachSpGoiY.Any()) { var allMenus = _menuRepository.GetAllMenuCache(); products = (from m in allMenus where DanhsachSpGoiY.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(8).ToList(); } } IList <PromotionMapping.PromotionCheckProduct> promotions = _promotionRepository.GetActives(); PromotionMapping.GetPromotion(promotions, products); SanPhamCungXemModel model = new SanPhamCungXemModel() { Products = products, }; return(View("sanphamxemcung", model)); }