diff --git a/src/Client/src/app/pages/main/company/company.component.ts b/src/Client/src/app/pages/main/company/company.component.ts index 015c90d..d2955c9 100644 --- a/src/Client/src/app/pages/main/company/company.component.ts +++ b/src/Client/src/app/pages/main/company/company.component.ts @@ -5,8 +5,9 @@ import { Router, ActivatedRoute, RouterModule } from '@angular/router'; import { Title } from '@angular/platform-browser'; import { CommonModule } from '@angular/common'; import { Authentication } from 'app/services/Authentication'; -import { Company, Employee } from 'app/models/Company'; +import { Company } from 'app/models/Company'; import { JobListing } from 'app/models/JobListing'; +import { Employee } from 'app/models/Employee'; @Component({ selector: 'main-company', @@ -20,6 +21,7 @@ export class CompanyComponent { public Employers: Employee[] = []; public Comp: Company | null = null; + public CompEmployees: Employee[] = []; public Desc: string[] = []; public List: JobListing[] = []; @@ -39,7 +41,6 @@ export class CompanyComponent { this.ErrorMsg = err.error; } }); - }; changeSelectedCompany(companyID: number){ @@ -61,6 +62,15 @@ export class CompanyComponent { this.ErrorMsg = err.error; } }); + + this.http.get("api/employee/" + companyID).subscribe({ + next: data => { + this.CompEmployees = data; + }, + error: err => { + this.ErrorMsg = err.error; + } + }); } RemoveJobListing( JobListingID: number ){ diff --git a/src/Client/src/app/pages/main/jobs/editor/jobeditor.component.ts b/src/Client/src/app/pages/main/jobs/editor/jobeditor.component.ts index b5522dc..6033f17 100644 --- a/src/Client/src/app/pages/main/jobs/editor/jobeditor.component.ts +++ b/src/Client/src/app/pages/main/jobs/editor/jobeditor.component.ts @@ -6,7 +6,6 @@ import { Title } from '@angular/platform-browser'; import { CommonModule } from '@angular/common'; import { JobListing } from 'app/models/JobListing'; import { Authentication } from 'app/services/Authentication'; -import { Company, Employee } from 'app/models/Company'; @Component({ selector: 'main-jobs-editor', @@ -85,35 +84,20 @@ export class JobEditorComponent { this.updateUI(); } - PostNewJob(jobListing: JobListing){ - jobListing.companyID = this.modeID; - this.http.post("api/joblisting", jobListing).subscribe({ - next: data => { - this.router.navigate([""]); - }, - error: err => { - this.ErrorMsg = err.error; - } - }); - } - - PostEditJob(jobListing: JobListing){ - this.http.post("api/joblisting", jobListing).subscribe({ - next: data => { - this.router.navigate([""]); - }, - error: err => { - this.ErrorMsg = err.error; - } - }); - } - - SubmitForm(job: JobListing){ + SubmitForm(jobListing: JobListing){ if (this.mode === "new"){ - this.PostNewJob(job); - }else if (this.mode === "edit"){ - this.PostEditJob(job); + jobListing.companyID = this.modeID; + } else if (this.mode === "edit"){ + jobListing.id = this.modeID; } + this.http.post("api/joblisting", jobListing).subscribe({ + next: data => { + this.router.navigate([""]); + }, + error: err => { + this.ErrorMsg = err.error; + } + }); } } \ No newline at end of file diff --git a/src/Client/src/app/pages/main/jobs/jobs.component.ts b/src/Client/src/app/pages/main/jobs/jobs.component.ts index 6f1d451..ac6d208 100644 --- a/src/Client/src/app/pages/main/jobs/jobs.component.ts +++ b/src/Client/src/app/pages/main/jobs/jobs.component.ts @@ -39,15 +39,4 @@ export class JobsComponent { }; - RemoveJobListing( JobListingID: number ){ - this.http.delete("api/joblisting?JobListingID=" + JobListingID).subscribe({ - next: data => { - window.location.reload(); - }, - error: err => { - this.ErrorMsg = err.error; - } - }); - } - } \ No newline at end of file diff --git a/src/Server/Controllers/AuthenticationController.cs b/src/Server/Controllers/AuthenticationController.cs index 96180d4..7fe6825 100755 --- a/src/Server/Controllers/AuthenticationController.cs +++ b/src/Server/Controllers/AuthenticationController.cs @@ -12,7 +12,7 @@ namespace BoredCareers.Controllers { public AuthenticationController(DatabaseService db) : base(db) { } - [HttpPost("loginState")] + [HttpPost("loginstate")] public ActionResult LoginState() { if (isLoggedIn()) { return Ok(getLoggedInUser()); diff --git a/src/Server/Controllers/CompanyController.cs b/src/Server/Controllers/CompanyController.cs index c37edba..7838f2c 100644 --- a/src/Server/Controllers/CompanyController.cs +++ b/src/Server/Controllers/CompanyController.cs @@ -35,8 +35,12 @@ namespace BoredCareers.Controllers { 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, + AccountEmail = getLoggedInUser().Email, Company = company }); return Ok(); @@ -66,7 +70,7 @@ namespace BoredCareers.Controllers { } [HttpGet("sendverifyemail")] - public async Task> SendVerify([FromQuery] int CompanyID) { + public async Task SendVerify([FromQuery] int CompanyID) { try { string key = "v" + CompanyID; // Stop from sending multiple emails quickly @@ -99,7 +103,7 @@ namespace BoredCareers.Controllers { } [HttpGet("verifyemail")] - public async Task> VerifyEmail([FromQuery] int CompanyID, [FromQuery] string EmailToken) { + public async Task VerifyEmail([FromQuery] int CompanyID, [FromQuery] string EmailToken) { try { Company? test = await _databaseService.GetCompany(CompanyID); if (test != null) {