/// <summary> /// This method fetches Home Page /// </summary> /// <param name="SearchString"></param> /// <param name="sortOrder"></param> /// <param name="pageNumber"></param> /// <param name="s"></param> /// <returns></returns> public async Task <IActionResult> Index(string SearchString, string sortOrder, int?pageNumber, string s) { if (User.IsInRole("Admin")) { return(RedirectToAction("AdminIndex", "Home")); } if (User.IsInRole("Interviewer")) { return(RedirectToAction("InterviewerIndex", "Home")); } else { //for candidate conflict if (s != null) { ViewData["msg"] = s; } ViewData["CurrentSort"] = sortOrder; ViewData["TitleSortParm"] = String.IsNullOrEmpty(sortOrder) ? "job_title" : ""; ViewData["LocationSortParm"] = String.IsNullOrEmpty(sortOrder) ? "location" : ""; ViewData["JobRoleSortParm"] = String.IsNullOrEmpty(sortOrder) ? "job_role" : ""; ViewData["JobTypeSortParm"] = String.IsNullOrEmpty(sortOrder) ? "job_type" : ""; IQueryable <JobPostViewModel> plist = await _jobPostPage.getJobPost(); //IEnumerable<JobPostViewModel> newlist; //newlist = plist.ToList(); //foreach(var item in newlist) //{ // item.EncryptionId = _Protector.Protect(item.ID.ToString()); //} //plist = newlist.AsQueryable(); //foreach(var item in plist) //{ // item.EncryptionId = _Protector.Protect(item.ID.ToString()); //} //plist = plist.Select(c => //{ // c.EncryptionId = _Protector.Protect(c.ID.ToString()); //}); try { if (!String.IsNullOrEmpty(SearchString)) { plist = plist.Where(s => s.job_title.ToUpper().Contains(SearchString.ToUpper()) || s.location.ToUpper().Contains(SearchString.ToUpper()) || s.job_role.ToUpper().Contains(SearchString.ToUpper()) || s.job_type.ToUpper().Contains(SearchString.ToUpper())); } switch (sortOrder) { case "job_title": plist = plist.OrderByDescending(s => s.job_title); break; case "location": plist = plist.OrderBy(s => s.location); break; case "job_role": plist = plist.OrderByDescending(s => s.job_role); break; case "job_type": plist = plist.OrderByDescending(s => s.job_type); break; default: plist = plist.OrderBy(s => s.job_title); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); } //for sorting int pageSize = 4; return(View(await PaginatedList <JobPostViewModel> .CreateAsync(plist.AsNoTracking(), pageNumber ?? 1, pageSize))); } }
public async Task <IActionResult> Index() { return(View(await _jobPostPageservices.getJobPost())); }