public ActionResult NewsHome(int?page, string id, DateTime?search, DateTime?searchto, string keyword) { ViewBag.formdate = search != null?Convert.ToDateTime(search).ToString("MM/dd/yyyy") : ""; ViewBag.todate = searchto != null?Convert.ToDateTime(searchto).ToString("MM/dd/yyyy") : ""; int pageSize = 6; NewsDataStore n = new NewsDataStore(); ViewBag.f = n.GetFirstProduct(); ProductDataStore p = new ProductDataStore(); NewsHomeViewModel model = new NewsHomeViewModel(); if (Session["UserRole"] != null && Session["UserRole"].ToString().ToUpper() == "CUSTOMER") { model.NewsList = n.GetNewsBySearch(id, search, searchto, keyword).OrderByDescending(x => x.CreatedTime).ToPagedList(page ?? 1, pageSize); //model.NewsList = n.GetCustNewsList(Convert.ToInt32(Session["LoginUser"])).ToPagedList(page ?? 1, pageSize); } else { model.NewsList = n.GetNewsBySearch(id, search, searchto, keyword).OrderByDescending(x => x.CreatedTime).ToPagedList(page ?? 1, pageSize); } ViewBag.category = p.ProductList(); return(View(model)); }
public ActionResult NewsHome(int?page) { int pageSize = 6; NewsDataStore n = new NewsDataStore(); ProductDataStore p = new ProductDataStore(); NewsHomeViewModel model = new NewsHomeViewModel(); //ViewBag.formdate = new DateTime(DateTime.Now.Year,DateTime.Now.Month,01).ToString("MM/dd/yyyy"); //ViewBag.todate = DateTime.Now.ToString("MM/dd/yyyy"); if (Session["UserRole"] != null && Session["UserRole"].ToString().ToUpper() == "CUSTOMER") { model.NewsList = n.GetCustNewsList(Convert.ToInt32(Session["LoginUser"])).ToPagedList(page ?? 1, pageSize); } else { model.NewsList = n.GetNewsList().ToPagedList(page ?? 1, pageSize); } ViewBag.category = p.ProductList(); return(View(model)); }