Update SetCompany API for better ease of use

This commit is contained in:
2025-08-19 20:39:59 -07:00
parent ade5ac1212
commit 8bb8b4aedf
+4 -5
View File
@@ -29,14 +29,12 @@ namespace BoredCareers.Controllers {
}
[HttpPost]
public async Task<IActionResult> SetCompany([FromBody] Company company, [FromQuery] bool newCompany = false) {
public async Task<IActionResult> SetCompany([FromBody] Company company) {
if (isLoggedIn()) {
if (newCompany) {
Company? test = await _databaseService.GetCompany(Convert.ToInt32(company.ID));
if (test == null) {
company.ID = await _databaseService.SetCompany(company);
await _databaseService.SetEmployee(new Employee() {
AccountID = getLoggedInUserID(),
AccountName = getLoggedInUser().UserName,
@@ -44,10 +42,11 @@ namespace BoredCareers.Controllers {
Company = company
});
return Ok();
}
return NotFound("The company already exists");
} else {
if (await isLoggedInUserEmployeeOf(Convert.ToInt32(company.ID))) {
if (company.Email != test.Email) {
company.EmailVerified = false;
}
await _databaseService.SetCompany(company);
return Ok();
}