Finalize Services
This commit is contained in:
@@ -10,17 +10,14 @@ namespace BoredCareers.Controllers {
|
||||
|
||||
public JobListingController(DatabaseService db) : base(db) {}
|
||||
|
||||
[Route("getlistings")]
|
||||
[Route("getpage")]
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> GetJobListings([FromForm] int page) {
|
||||
if (isLoggedIn()) {
|
||||
JobListing[] jobListings = await _databaseService.GetJobListingPage(page, 25); // 10 items per page
|
||||
return Ok(jobListings);
|
||||
}
|
||||
return NotFound();
|
||||
JobListing[] jobListings = await _databaseService.GetJobListingPage(page, 25); // 10 items per page
|
||||
return Ok(jobListings);
|
||||
}
|
||||
|
||||
[Route("getlisting")]
|
||||
[Route("get")]
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> GetJobListing([FromForm] int JobListingID) {
|
||||
JobListing? jobListing = await _databaseService.GetJobListing(JobListingID);
|
||||
@@ -32,16 +29,27 @@ namespace BoredCareers.Controllers {
|
||||
|
||||
[Route("set")]
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> SetJobListing([FromBody] Resume resume) {
|
||||
await Task.Delay(1);
|
||||
return Ok();
|
||||
public async Task<IActionResult> SetJobListing([FromBody] JobListing jobListing) {
|
||||
if (isLoggedIn()) {
|
||||
if (await isLoggedInUserEmployeeOf(jobListing.CompanyID)) {
|
||||
await _databaseService.SetJobListing(jobListing);
|
||||
}
|
||||
}
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
[Route("delete")]
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> DeleteJobListing([FromForm] int ResumeID) {
|
||||
await Task.Delay(1);
|
||||
return Ok();
|
||||
public async Task<IActionResult> DeleteJobListing([FromForm] int JobListingID) {
|
||||
if (isLoggedIn()) {
|
||||
JobListing? jobListing = await _databaseService.GetJobListing(JobListingID);
|
||||
if (jobListing != null) {
|
||||
if (await isLoggedInUserEmployeeOf(JobListingID)) {
|
||||
await _databaseService.DeleteJobListing(JobListingID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user