public ActionResult News() { shNewService _tintuc = new shNewService(); IEnumerable <shNew> dsNews = _tintuc.DanhSachNews() .ToPagedList(1, 5); return(PartialView(dsNews)); }
public ActionResult NewsRelated(string NewGuiId) { shNewService _tintuc = new shNewService(); IEnumerable <shNew> dsNews = _tintuc.DanhSachNews() .Where(x => x.NewGuiId != NewGuiId) .ToPagedList(1, 10); return(PartialView("NewsRelated", dsNews)); }
public ActionResult Details(int?id) { shNewService _tintuc = new shNewService(); shNew tintuc = _tintuc.FindList().Where(x => x.NewId == id).FirstOrDefault(); if (tintuc == null) { tintuc = new shNew(); } return(View(tintuc)); }
public PartialViewResult ListNews(int?page) { int pageCurrent = 1; if (page.HasValue) { pageCurrent = page.Value; } shNewService _new = new shNewService(); IPagedList <shNew> dsNews = _new.DanhSachNews_PhanTrang(pageCurrent, Config.PAGE_SIZE_10); ViewBag.ListNews = dsNews; return(PartialView("ListNews", dsNews)); }
public ActionResult DsNews(int?page) { int pageCurrent = 1; if (page.HasValue) { pageCurrent = page.Value; } shNewService _tintuc = new shNewService(); IPagedList <shNew> dsNew = _tintuc.DanhSachNews_PhanTrang(pageCurrent, Config.PAGE_SIZE_9); ViewBag.DsNews = dsNew; return(PartialView("DsNews", ViewBag.DsNews)); }
public ActionResult Create(string id) { if (!string.IsNullOrWhiteSpace(id)) { shNewService _new = new shNewService(); shNew tintuc = _new.FindByKey(id); if (tintuc != null) { return(View(tintuc)); } else { return(View(new shNew())); } } return(View(new shNew())); }
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); }
public ActionResult Create(string NewGuiId, int?NewId, string TitleNew, int?SortOrder, string Descriptions, string Summary, string Contents, bool?Status, string ImageFile) { shNewService _new = new shNewService(); using (var context = new ShopOnlineDb()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { if (!string.IsNullOrWhiteSpace(NewGuiId)) { NewId = 0; } // check if contents ( ckeditor) null then rollback và yêu cầu người dùng nhập lại if (string.IsNullOrEmpty(Contents)) { shNew shnew = _new.FindByKey(NewGuiId); if (shnew == null) { shnew = new shNew(); } //shnew.NewId = NewId.Value; //shnew.Title = Title1; ViewBag.TitleNew = TitleNew; shnew.SortOrder = SortOrder; shnew.Descriptions = Descriptions; shnew.Summary = Summary; shnew.Contents = Contents; shnew.Status = Status; shnew.ImageFile = ImageFile; ModelState.AddModelError("", "Nội dung không được trống. Xin Vui lòng kiểm tra lại. "); return(View(shnew)); } shNew tintuc = _new.ThemMoi_HieuChinhshNew( NewGuiId, null, TitleNew, Descriptions, ImageFile, Summary, Contents, SortOrder, Status, DateTime.Now); dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); } } } return(RedirectToAction("Index")); }