예제 #1
0
        public ActionResult DealsHome(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 nc       = new NewsDataStore();

            ViewBag.f = nc.GetFirstProduct();
            DealsDataStore     n     = new DealsDataStore();
            ProductDataStore   p     = new ProductDataStore();
            DealsHomeViewModel model = new DealsHomeViewModel();

            if (Session["UserRole"] != null && Session["UserRole"].ToString().ToUpper() == "CUSTOMER")
            {
                model.DealsList = n.GetDealsBySearch(id, search, searchto, keyword).OrderByDescending(x => x.CreatedTime).ToPagedList(page ?? 1, pageSize);
                //model.DealsList = n.GetCustDealsList(Convert.ToInt32(Session["LoginUser"])).ToPagedList(page ?? 1, pageSize);
            }

            else
            {
                model.DealsList = n.GetDealsBySearch(id, search, searchto, keyword).OrderByDescending(x => x.CreatedTime).ToPagedList(page ?? 1, pageSize);
            }
            ViewBag.category = p.ProductList();
            return(View(model));
        }
예제 #2
0
        public ActionResult DealsHome(int?page)
        {
            //int pageSize = 6;
            //DealsDataStore d = new DealsDataStore();
            //var model= d.GetDealsList().ToPagedList(page ?? 1, pageSize);
            //return View(model);
            NewsDataStore nc = new NewsDataStore();

            ViewBag.f = nc.GetFirstProduct();
            int                pageSize = 6;
            DealsDataStore     n        = new DealsDataStore();
            ProductDataStore   p        = new ProductDataStore();
            DealsHomeViewModel model    = new DealsHomeViewModel();

            if (Session["UserRole"] != null && Session["UserRole"].ToString().ToUpper() == "CUSTOMER")
            {
                model.DealsList = n.GetCustDealsList(Convert.ToInt32(Session["LoginUser"])).ToPagedList(page ?? 1, pageSize);
            }

            else
            {
                model.DealsList = n.GetDealsList().ToPagedList(page ?? 1, pageSize);
            }

            ViewBag.f        = n.GetFirstProduct();
            ViewBag.category = p.ProductList();
            return(View(model));
        }