public async Task <IActionResult> PutJob(int id, JobEntity jobEntity) { if (id != jobEntity.JobId) { return(BadRequest()); } try { await logic.UpdateJob(jobEntity); } catch (DbUpdateConcurrencyException) { if (!JobExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task Test_BL_UpdateJob() { //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 newjob.Title = ".NET Developer"; await businessLogic.UpdateJob(newjob); var updatedJob = await businessLogic.GetJob(newjob.JobId); //Assert Assert.True(updatedJob.Title == ".NET Developer", "Job updated"); }
public async Task <IActionResult> Edit(int id, [Bind("JobId,Title,Description,CreatedAt,ExpiresAt")] JobEntity jobEntity) { if (id != jobEntity.JobId) { return(NotFound()); } if (ModelState.IsValid) { try { await jobslogic.UpdateJob(jobEntity); } catch (DbUpdateConcurrencyException) { if (!jobslogic.JobExists(jobEntity.JobId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(jobEntity)); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } try { await logic.UpdateJob(JobEntity); } catch (DbUpdateConcurrencyException) { if (!JobEntityExists(JobEntity.JobId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }