working #31
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user