Start work on Company New

This commit is contained in:
2025-07-18 19:55:53 -07:00
parent 1ef887166a
commit d8762408d4
5 changed files with 340 additions and 7 deletions
+19 -7
View File
@@ -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");
}
}