示例#1
0
        public async Task <ActionResult> Index()
        {
            var indexVm = new IndexProExpViewModel
            {
                ProExpModels = new List <ProExpModel>(await _proExpService.GetAllProExpFrom(_userModel))
            };

            return(View(indexVm));
        }
示例#2
0
        public async Task <ActionResult> Index(string sortOrder, string searchString)
        {
            ViewBag.CitySortParm     = String.IsNullOrEmpty(sortOrder) ? "city_desc" : "";
            ViewBag.CompanySortParm  = String.IsNullOrEmpty(sortOrder) ? "company_desc" : "";
            ViewBag.FromDateSortParm = sortOrder == "FromDate" ? "fromDate_desc" : "FromDate";
            ViewBag.ToDateSortParm   = sortOrder == "ToDate" ? "toDate_desc" : "ToDate";
            var indexVm = new IndexProExpViewModel
            {
                ProExpModels = new List <ProExpModel>(await _proExpService.GetAllProExpFrom(_userModel))
            };

            if (!String.IsNullOrEmpty(searchString))
            {
                indexVm.ProExpModels = indexVm.ProExpModels.Where(s => s.CityName.ToLower().Contains(searchString.ToLower()) ||
                                                                  s.CompanyName.ToLower().Contains(searchString.ToLower())).ToList();
            }
            switch (sortOrder)
            {
            case "city_desc":
                indexVm.ProExpModels = indexVm.ProExpModels.OrderByDescending(s => s.CityName).ToList();
                break;

            case "company_desc":
                indexVm.ProExpModels = indexVm.ProExpModels.OrderByDescending(s => s.CompanyName).ToList();
                break;

            case "FromDate":
                indexVm.ProExpModels = indexVm.ProExpModels.OrderBy(s => s.FromDate).ToList();
                break;

            case "fromDate_desc":
                indexVm.ProExpModels = indexVm.ProExpModels.OrderByDescending(s => s.FromDate).ToList();
                break;

            case "ToDate":
                indexVm.ProExpModels = indexVm.ProExpModels.OrderBy(s => s.ToDate).ToList();
                break;

            case "toDate_desc":
                indexVm.ProExpModels = indexVm.ProExpModels.OrderByDescending(s => s.ToDate).ToList();
                break;
            }
            return(View(indexVm));
        }