Code Cleanup
This commit is contained in:
@@ -5,8 +5,9 @@ import { Router, ActivatedRoute, RouterModule } from '@angular/router';
|
|||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Authentication } from 'app/services/Authentication';
|
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 { JobListing } from 'app/models/JobListing';
|
||||||
|
import { Employee } from 'app/models/Employee';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'main-company',
|
selector: 'main-company',
|
||||||
@@ -20,6 +21,7 @@ export class CompanyComponent {
|
|||||||
public Employers: Employee[] = [];
|
public Employers: Employee[] = [];
|
||||||
|
|
||||||
public Comp: Company | null = null;
|
public Comp: Company | null = null;
|
||||||
|
public CompEmployees: Employee[] = [];
|
||||||
public Desc: string[] = [];
|
public Desc: string[] = [];
|
||||||
|
|
||||||
public List: JobListing[] = [];
|
public List: JobListing[] = [];
|
||||||
@@ -39,7 +41,6 @@ export class CompanyComponent {
|
|||||||
this.ErrorMsg = err.error;
|
this.ErrorMsg = err.error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
changeSelectedCompany(companyID: number){
|
changeSelectedCompany(companyID: number){
|
||||||
@@ -61,6 +62,15 @@ export class CompanyComponent {
|
|||||||
this.ErrorMsg = err.error;
|
this.ErrorMsg = err.error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.http.get<Employee[]>("api/employee/" + companyID).subscribe({
|
||||||
|
next: data => {
|
||||||
|
this.CompEmployees = data;
|
||||||
|
},
|
||||||
|
error: err => {
|
||||||
|
this.ErrorMsg = err.error;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveJobListing( JobListingID: number ){
|
RemoveJobListing( JobListingID: number ){
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { Title } from '@angular/platform-browser';
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { JobListing } from 'app/models/JobListing';
|
import { JobListing } from 'app/models/JobListing';
|
||||||
import { Authentication } from 'app/services/Authentication';
|
import { Authentication } from 'app/services/Authentication';
|
||||||
import { Company, Employee } from 'app/models/Company';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'main-jobs-editor',
|
selector: 'main-jobs-editor',
|
||||||
@@ -85,35 +84,20 @@ export class JobEditorComponent {
|
|||||||
this.updateUI();
|
this.updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
PostNewJob(jobListing: JobListing){
|
SubmitForm(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){
|
|
||||||
if (this.mode === "new"){
|
if (this.mode === "new"){
|
||||||
this.PostNewJob(job);
|
jobListing.companyID = this.modeID;
|
||||||
} else if (this.mode === "edit"){
|
} else if (this.mode === "edit"){
|
||||||
this.PostEditJob(job);
|
jobListing.id = this.modeID;
|
||||||
}
|
}
|
||||||
|
this.http.post("api/joblisting", jobListing).subscribe({
|
||||||
|
next: data => {
|
||||||
|
this.router.navigate([""]);
|
||||||
|
},
|
||||||
|
error: err => {
|
||||||
|
this.ErrorMsg = err.error;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ namespace BoredCareers.Controllers {
|
|||||||
|
|
||||||
public AuthenticationController(DatabaseService db) : base(db) { }
|
public AuthenticationController(DatabaseService db) : base(db) { }
|
||||||
|
|
||||||
[HttpPost("loginState")]
|
[HttpPost("loginstate")]
|
||||||
public ActionResult<Account> LoginState() {
|
public ActionResult<Account> LoginState() {
|
||||||
if (isLoggedIn()) {
|
if (isLoggedIn()) {
|
||||||
return Ok(getLoggedInUser());
|
return Ok(getLoggedInUser());
|
||||||
|
|||||||
@@ -35,8 +35,12 @@ namespace BoredCareers.Controllers {
|
|||||||
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,
|
||||||
|
AccountEmail = getLoggedInUser().Email,
|
||||||
Company = company
|
Company = company
|
||||||
});
|
});
|
||||||
return Ok();
|
return Ok();
|
||||||
@@ -66,7 +70,7 @@ namespace BoredCareers.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("sendverifyemail")]
|
[HttpGet("sendverifyemail")]
|
||||||
public async Task<ActionResult<string>> SendVerify([FromQuery] int CompanyID) {
|
public async Task<ActionResult> SendVerify([FromQuery] int CompanyID) {
|
||||||
try {
|
try {
|
||||||
string key = "v" + CompanyID;
|
string key = "v" + CompanyID;
|
||||||
// Stop from sending multiple emails quickly
|
// Stop from sending multiple emails quickly
|
||||||
@@ -99,7 +103,7 @@ namespace BoredCareers.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("verifyemail")]
|
[HttpGet("verifyemail")]
|
||||||
public async Task<ActionResult<bool>> VerifyEmail([FromQuery] int CompanyID, [FromQuery] string EmailToken) {
|
public async Task<ActionResult> VerifyEmail([FromQuery] int CompanyID, [FromQuery] string EmailToken) {
|
||||||
try {
|
try {
|
||||||
Company? test = await _databaseService.GetCompany(CompanyID);
|
Company? test = await _databaseService.GetCompany(CompanyID);
|
||||||
if (test != null) {
|
if (test != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user