Better verbosity for API

This commit is contained in:
2025-07-18 19:56:09 -07:00
parent d8762408d4
commit ce24ea478d
2 changed files with 14 additions and 8 deletions
@@ -16,7 +16,7 @@ namespace BoredCareers.Controllers {
if (jobListing != null) { if (jobListing != null) {
return Ok(jobListing); return Ok(jobListing);
} }
return NotFound(); return NotFound("Job listing not found");
} }
[HttpGet] [HttpGet]
@@ -32,8 +32,9 @@ namespace BoredCareers.Controllers {
await _databaseService.SetJobListing(JobListing); await _databaseService.SetJobListing(JobListing);
return Ok(); return Ok();
} }
return NotFound("You are not an employee of company");
} }
return NotFound(); return NotFound("Not logged in");
} }
[HttpDelete] [HttpDelete]
@@ -45,9 +46,11 @@ namespace BoredCareers.Controllers {
await _databaseService.DeleteJobListing(JobListingID); await _databaseService.DeleteJobListing(JobListingID);
return Ok(); return Ok();
} }
return NotFound("You are not an employee of company");
} }
return NotFound("Job listing doesn't exist already");
} }
return NotFound(); return NotFound("Not logged in");
} }
} }
+8 -5
View File
@@ -17,14 +17,15 @@ namespace BoredCareers.Controllers {
if (resume != null) { if (resume != null) {
return Ok(resume); return Ok(resume);
} }
}else{ return NotFound("Unable to find resume");
} else {
if (isLoggedIn()) { if (isLoggedIn()) {
int accountID = getLoggedInUserID(); int accountID = getLoggedInUserID();
Resume[] resumes = await _databaseService.GetResumes(accountID); Resume[] resumes = await _databaseService.GetResumes(accountID);
return Ok(resumes); return Ok(resumes);
} }
return NotFound("Not logged in");
} }
return NotFound();
} }
[HttpPost] [HttpPost]
@@ -35,21 +36,23 @@ namespace BoredCareers.Controllers {
await _databaseService.SetResume(resume); await _databaseService.SetResume(resume);
return Ok(); return Ok();
} }
return NotFound("Resume doesn't exist or you are not the owner");
} }
return NotFound(); return NotFound("Not logged in");
} }
[HttpDelete] [HttpDelete]
public async Task<IActionResult> DeleteResume(int ResumeID) { public async Task<IActionResult> DeleteResume(int ResumeID) {
if (isLoggedIn()){ if (isLoggedIn()) {
int accountID = getLoggedInUserID(); int accountID = getLoggedInUserID();
Resume? resume = await _databaseService.GetResume(ResumeID); Resume? resume = await _databaseService.GetResume(ResumeID);
if (resume != null && resume.AccountID == accountID) { if (resume != null && resume.AccountID == accountID) {
await _databaseService.DeleteResume(ResumeID); await _databaseService.DeleteResume(ResumeID);
return Ok(); return Ok();
} }
return NotFound("Resume doesn't exist or you are not the owner");
} }
return NotFound(); return NotFound("Not logged in");
} }
} }