public ActionResult Details(int?id) { shProductService _product = new shProductService(); shProduct product = _product.FindList().Where(x => x.ProductId == id).FirstOrDefault(); shProductImageService _productImage = new shProductImageService(); IEnumerable <shProductImage> dsImage = _productImage.DanhSachProductImage_ByProductGuid(product.ProductGuid); ViewBag.dsImageMauMa = dsImage.Where(x => x.ProductImageCategory == Config.ProductImageCategory_Design); ViewBag.dsImageChatLieu = dsImage.Where(x => x.ProductImageCategory == Config.ProductImageCategory_Material); shSectionService _section = new shSectionService(); IEnumerable <shProductSet> dsSection = _section.DanhSachSection_TheoProductGuid_ParentNull(product.ProductGuid); shProductSet section = new shProductSet(); if (dsSection != null && dsSection.Count() > 0) { section = dsSection.FirstOrDefault(); } shSizeService _size = new shSizeService(); IEnumerable <shSetSize> dsSize = _size.DanhSachSize_BySectionGuid(section.SectionGuid, product.ProductGuid, null); ViewBag.ProductSize = section.SectionName + " --- " + CommonHelper.TinhToanKichThuocMaxMin(dsSize.FirstOrDefault(), dsSize.LastOrDefault()); ViewBag.ProductPrice = CommonHelper.TinhToanGiaTienMaxMin(dsSize.FirstOrDefault(), dsSize.LastOrDefault()); // Tính toán số tiền sau khuyến mại string productSale = CommonHelper.TinhToanGiaTienSauKhiGiam(dsSize.FirstOrDefault(), dsSize.LastOrDefault()); if (!string.IsNullOrEmpty(productSale) && !string.IsNullOrWhiteSpace(productSale)) { ViewBag.ProductSale = Format.FormatDecimalToString(Convert.ToDecimal(productSale)); } ViewBag.ListSection = dsSection; return(View(product)); }
public IEnumerable <TimKiemNangCao> TimKiemNangCao(string keyword) { List <TimKiemNangCao> ds = new List <TimKiemNangCao>(); TimKiemNangCao timkiem = new TimKiemNangCao(); // 1. Tìm kiếm trong bảng sản phẩm shProductService _product = new shProductService(); IEnumerable <shProduct> dsProduct = _product.FindList().Where(x => TypeHelper.CompareString(x.ProductName, keyword)); foreach (var product in dsProduct) { timkiem = new TimKiemNangCao(); timkiem.CategoryId = TheLoaiTimKiemNangCao.SanPham.GetHashCode(); timkiem.Category = "Sản phẩm"; timkiem.Name = product.ProductName; timkiem.MetaTitle = product.MetaTitle + "-" + product.ProductId; timkiem.keyword = keyword; timkiem.CreatedDate = product.CreateDate; timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: Kích ..."; timkiem.ProductGuid = product.ProductGuid; ds.Add(timkiem); } // 3. Tìm kiếm trong bảng set sản phẩm shSectionService _section = new shSectionService(); IEnumerable <shProductSet> dsSet = _section.FindList().Where(x => TypeHelper.CompareString(x.SectionName, keyword)); foreach (var set in dsSet) { shProduct product = _product.FindByKey(set.ProductGuid); timkiem = new TimKiemNangCao(); timkiem.CategoryId = TheLoaiTimKiemNangCao.SetSanPham.GetHashCode(); timkiem.Category = "Sản phẩm"; timkiem.Name = product.ProductName + "- Set " + set.SectionName + keyword; timkiem.MetaTitle = product.MetaTitle + "-" + product.ProductId; timkiem.keyword = keyword; timkiem.CreatedDate = set.CreateDate; timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: Kích ..."; timkiem.ProductGuid = product.ProductGuid; ds.Add(timkiem); } // 4. Tìm kiếm trong bảng kích thước theo set shSizeService _size = new shSizeService(); IEnumerable <shSetSize> dsSize = _size.FindList().Where(x => TypeHelper.CompareString(x.SizeName, keyword)); foreach (var size in dsSize) { shProduct product = _product.FindByKey(size.ProductGuid); timkiem = new TimKiemNangCao(); timkiem.CategoryId = TheLoaiTimKiemNangCao.SetSanPham.GetHashCode(); timkiem.Category = "Sản phẩm"; timkiem.Name = product.ProductName + " - Kích thước: " + size.SizeName; timkiem.MetaTitle = product.MetaTitle + "-" + product.ProductId; timkiem.keyword = keyword; timkiem.CreatedDate = size.CreateDate; timkiem.Description = " Bộ sản phẩm có kết cấu và giá sản phẩm: Kích ..."; timkiem.ProductGuid = product.ProductGuid; ds.Add(timkiem); } // 2. Tìm kiếm trong bảng tin tức shNewService _new = new shNewService(); IEnumerable <shNew> dsNew = _new.FindList().Where(x => TypeHelper.CompareString(x.TitleNew, keyword)); foreach (var news in dsNew) { timkiem = new TimKiemNangCao(); timkiem.CategoryId = TheLoaiTimKiemNangCao.TinTuc.GetHashCode(); timkiem.Category = "Tin Tức"; timkiem.Name = news.TitleNew; timkiem.MetaTitle = news.MetaTitle + "-" + news.NewId; timkiem.keyword = keyword; timkiem.CreatedDate = news.CreatedDate; timkiem.Description = news.Summary; ds.Add(timkiem); } return(ds); }