public async Task Test_BL_ListJobs() { //Arrange JobBusinessLogic businessLogic = new JobBusinessLogic(inMemory: true); //Act JobEntity newjob1 = new JobEntity() { JobId = 1, Title = ".Net Developer", CreatedAt = DateTime.Now, ExpiresAt = DateTime.Now.AddDays(30) }; await businessLogic.CreateJob(newjob1); JobEntity newjob2 = new JobEntity() { JobId = 2, Title = "Backend Senior Developer", CreatedAt = DateTime.Now, ExpiresAt = DateTime.Now.AddDays(30) }; await businessLogic.CreateJob(newjob2); var list = await businessLogic.ListJobs(); //Assert Assert.True(list.Count == 2, $"{list.Count} Jobs listed"); }
/* * // GET: JobEntities * public async Task<IActionResult> Index() * { * return View(await jobslogic.ListJobs()); * }*/ // GET: JobEntities public async Task <IActionResult> Index( string sortOrder, string currentFilter, string searchString, int?pageNumber) { ViewData["CurrentSort"] = sortOrder; ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; if (searchString != null) { pageNumber = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; var jobsTask = await jobslogic.ListJobs(); var jobs = jobsTask.AsQueryable(); if (!String.IsNullOrEmpty(searchString)) { jobs = jobs.Where(s => s.Title.Contains(searchString, StringComparison.InvariantCultureIgnoreCase)); } switch (sortOrder) { case "name_desc": jobs = jobs.OrderByDescending(s => s.Title); break; case "Date": jobs = jobs.OrderBy(s => s.CreatedAt); break; case "date_desc": jobs = jobs.OrderByDescending(s => s.CreatedAt); break; default: jobs = jobs.OrderBy(s => s.Description); break; } int pageSize = 7; return(View(PaginatedList <JobEntity> .Create(jobs.AsNoTracking(), pageNumber ?? 1, pageSize))); }
public async Task <ActionResult <IEnumerable <JobEntity> > > GetJobs() { return(await logic.ListJobs()); }
public async Task OnGetAsync() { JobEntity = await logic.ListJobs(); }