working #31

Merged
derek merged 8 commits from working into main 2025-08-19 21:18:48 -07:00
Showing only changes of commit 8bb8b4aedf - Show all commits
+14 -15
View File
@@ -29,25 +29,24 @@ namespace BoredCareers.Controllers {
} }
[HttpPost] [HttpPost]
public async Task<IActionResult> SetCompany([FromBody] Company company, [FromQuery] bool newCompany = false) { public async Task<IActionResult> SetCompany([FromBody] Company company) {
if (isLoggedIn()) { if (isLoggedIn()) {
if (newCompany) { Company? test = await _databaseService.GetCompany(Convert.ToInt32(company.ID));
Company? test = await _databaseService.GetCompany(Convert.ToInt32(company.ID)); if (test == null) {
if (test == null) { company.ID = await _databaseService.SetCompany(company);
company.ID = await _databaseService.SetCompany(company);
await _databaseService.SetEmployee(new Employee() {
await _databaseService.SetEmployee(new Employee() { AccountID = getLoggedInUserID(),
AccountID = getLoggedInUserID(), AccountName = getLoggedInUser().UserName,
AccountName = getLoggedInUser().UserName, AccountEmail = getLoggedInUser().Email,
AccountEmail = getLoggedInUser().Email, Company = company
Company = company });
}); return Ok();
return Ok();
}
return NotFound("The company already exists");
} else { } else {
if (await isLoggedInUserEmployeeOf(Convert.ToInt32(company.ID))) { if (await isLoggedInUserEmployeeOf(Convert.ToInt32(company.ID))) {
if (company.Email != test.Email) {
company.EmailVerified = false;
}
await _databaseService.SetCompany(company); await _databaseService.SetCompany(company);
return Ok(); return Ok();
} }