Start work on Company New
This commit is contained in:
@@ -17,19 +17,30 @@ namespace BoredCareers.Controllers {
|
||||
if (company != null) {
|
||||
return Ok(company);
|
||||
}
|
||||
return NotFound("Company doesn't exist");
|
||||
}
|
||||
return NotFound();
|
||||
return NotFound("Not logged in");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> SetCompany([FromBody] Company company) {
|
||||
public async Task<IActionResult> SetCompany([FromBody] Company company, [FromQuery] bool newCompany = false) {
|
||||
if (isLoggedIn()) {
|
||||
if (await isLoggedInUserEmployeeOf(company.ID)) {
|
||||
await _databaseService.SetCompany(company);
|
||||
return Ok();
|
||||
if (newCompany) {
|
||||
Company? test = await _databaseService.GetCompany(company.ID);
|
||||
if (test == null) {
|
||||
await _databaseService.SetCompany(company);
|
||||
return Ok();
|
||||
}
|
||||
return NotFound("The company already exists");
|
||||
} else {
|
||||
if (await isLoggedInUserEmployeeOf(company.ID)) {
|
||||
await _databaseService.SetCompany(company);
|
||||
return Ok();
|
||||
}
|
||||
return NotFound("You are not an employee of company");
|
||||
}
|
||||
}
|
||||
return NotFound();
|
||||
return NotFound("Not logged in");
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
@@ -39,8 +50,9 @@ namespace BoredCareers.Controllers {
|
||||
await _databaseService.DeleteCompany(CompanyID);
|
||||
return Ok();
|
||||
}
|
||||
return NotFound("You are not an employee of company");
|
||||
}
|
||||
return NotFound();
|
||||
return NotFound("Not logged in");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user