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"); }
public async Task Test_BL_DeleteJob() { //Arrange JobBusinessLogic businessLogic = new JobBusinessLogic(inMemory: true); JobEntity newjob = new JobEntity() { JobId = 1, Title = "Backend Senior Developer", CreatedAt = DateTime.Now, ExpiresAt = DateTime.Now.AddDays(30) }; //Act await businessLogic.CreateJob(newjob); var exists = businessLogic.JobExists(newjob.JobId); //Assert Assert.True(exists, "Job created"); //Act await businessLogic.DeleteJob(newjob); exists = businessLogic.JobExists(newjob.JobId); //Assert Assert.False(exists, "Job deleted"); }
public async Task <IActionResult> Create([Bind("JobId,Title,Description,CreatedAt,ExpiresAt")] JobEntity jobEntity) { if (ModelState.IsValid) { await jobslogic.CreateJob(jobEntity); return(RedirectToAction(nameof(Index))); } return(View(jobEntity)); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } await logic.CreateJob(JobEntity); return(RedirectToPage("./Index")); }
public async Task <ActionResult <JobEntity> > PostJob(JobEntity jobEntity) { await logic.CreateJob(jobEntity); return(CreatedAtAction("GetJob", new { id = jobEntity.JobId }, jobEntity)); }