From 47bc07e327029ebdc619bd378cf4e67f73125fec Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Wed, 30 Jul 2025 22:01:02 -0700 Subject: [PATCH 1/3] Make DB id's nullable --- src/Client/src/app/models/Account.ts | 2 +- src/Client/src/app/models/Company.ts | 4 ++-- src/Client/src/app/models/JobListing.ts | 2 +- src/Client/src/app/models/Resume.ts | 20 ++++++++++---------- src/Server/Entities/Account.cs | 2 +- src/Server/Entities/Company.cs | 4 ++-- src/Server/Entities/JobListing.cs | 2 +- src/Server/Entities/Resume.cs | 20 ++++++++++---------- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Client/src/app/models/Account.ts b/src/Client/src/app/models/Account.ts index 12f75e0..45cf54a 100644 --- a/src/Client/src/app/models/Account.ts +++ b/src/Client/src/app/models/Account.ts @@ -1,5 +1,5 @@ export class Account { - public id: number = -1; + public id: number | null = null; public userName: string = ""; public email: string = ""; public emailVerified: boolean = false; diff --git a/src/Client/src/app/models/Company.ts b/src/Client/src/app/models/Company.ts index d0762ca..99a6eb7 100644 --- a/src/Client/src/app/models/Company.ts +++ b/src/Client/src/app/models/Company.ts @@ -1,5 +1,5 @@ export class Company { - public id: number = -1; + public id: number | null = null; public name: string = ""; public email: string = ""; public emailVerified: boolean = false; @@ -14,7 +14,7 @@ export class Company { } export class Employee { - public id: number = -1; + public id: number | null = null; public accountID: number = 0; public company: Company = new Company; } \ No newline at end of file diff --git a/src/Client/src/app/models/JobListing.ts b/src/Client/src/app/models/JobListing.ts index 18b9427..52fb396 100644 --- a/src/Client/src/app/models/JobListing.ts +++ b/src/Client/src/app/models/JobListing.ts @@ -1,5 +1,5 @@ export class JobListing { - public id: number = -1; + public id: number | null = null; public companyID: number = 0; public title: string = ""; public postalCode: string = ""; diff --git a/src/Client/src/app/models/Resume.ts b/src/Client/src/app/models/Resume.ts index 4ac970f..74e8ed9 100644 --- a/src/Client/src/app/models/Resume.ts +++ b/src/Client/src/app/models/Resume.ts @@ -1,5 +1,5 @@ export class Resume { - public id: number = -1; + public id: number | null = null; public accountID: number = 0; public name: string = ""; public field: string = ""; @@ -20,7 +20,7 @@ export class Resume { } export class ResumeExperience { - id: number = -1; + public id: number | null = null; resumeID: number = 0; jobTitle: string = ""; company: string = ""; @@ -35,14 +35,14 @@ export class ResumeExperience { } export class ResumeExperienceBullet { - id: number = -1; + public id: number | null = null; resumeID: number = 0; resumeExperienceID: number = 0; jobFunction: string = ""; } export class ResumeMilitary { - id: number = -1; + public id: number | null = null; resumeID: number = 0; country: string = ""; rank: string = ""; @@ -53,7 +53,7 @@ export class ResumeMilitary { } export class ResumeMilitaryBullet { - id: number = -1; + public id: number | null = null; resumeID: number = 0; resumeMilitaryID: number = 0; achievement: string = ""; @@ -61,7 +61,7 @@ export class ResumeMilitaryBullet { } export class ResumeEducation { - id: number = -1; + public id: number | null = null; resumeID: number = 0; degreeType: string = ""; degreeField: string = ""; @@ -76,21 +76,21 @@ export class ResumeEducation { } export class ResumeSkill { - id: number = -1; + public id: number | null = null; resumeID: number = 0; name: string = ""; description: string = ""; } export class ResumeLanguage { - id: number = -1; + public id: number | null = null; resumeID: number = 0; language: string = ""; proficiency: string = ""; } export class ResumeCertification { - id: number = -1; + public id: number | null = null; resumeID: number = 0; name: string = ""; verificationURL: string = ""; @@ -98,7 +98,7 @@ export class ResumeCertification { } export class ResumeProject { - id: number = -1; + public id: number | null = null; resumeID: number = 0; name: string = ""; url: string = ""; diff --git a/src/Server/Entities/Account.cs b/src/Server/Entities/Account.cs index 601a831..44897e3 100644 --- a/src/Server/Entities/Account.cs +++ b/src/Server/Entities/Account.cs @@ -1,6 +1,6 @@ namespace BoredCareers.Entities { public class Account { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public string UserName { get; set; } = ""; public string Email { get; set; } = ""; public string Role { get; set; } = "Generic"; diff --git a/src/Server/Entities/Company.cs b/src/Server/Entities/Company.cs index dfa85eb..cd8fbae 100644 --- a/src/Server/Entities/Company.cs +++ b/src/Server/Entities/Company.cs @@ -1,7 +1,7 @@ namespace BoredCareers.Entities { public class Company { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public string Name { get; set; } = ""; public string Email { get; set; } = ""; public bool EmailVerified { get; set; } = false; @@ -16,7 +16,7 @@ namespace BoredCareers.Entities { } public class Employee { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int AccountID { get; set; } // FK public Company Company { get; set; } = new Company(); // FK } diff --git a/src/Server/Entities/JobListing.cs b/src/Server/Entities/JobListing.cs index f88744e..f4fdc5f 100644 --- a/src/Server/Entities/JobListing.cs +++ b/src/Server/Entities/JobListing.cs @@ -1,7 +1,7 @@ namespace BoredCareers.Entities { public class JobListing { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int CompanyID { get; set; } // FK public string Title { get; set; } = ""; public string PostalCode { get; set; } = ""; diff --git a/src/Server/Entities/Resume.cs b/src/Server/Entities/Resume.cs index 55b58c0..bef81bf 100644 --- a/src/Server/Entities/Resume.cs +++ b/src/Server/Entities/Resume.cs @@ -1,7 +1,7 @@ namespace BoredCareers.Entities { public class Resume { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int AccountID { get; set; } // FK public string Name { get; set; } = ""; public string Field { get; set; } = ""; @@ -22,7 +22,7 @@ namespace BoredCareers.Entities { } public class ResumeExperience { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int ResumeID { get; set; } // FK public string JobTitle { get; set; } = ""; public string Company { get; set; } = ""; @@ -37,14 +37,14 @@ namespace BoredCareers.Entities { } public class ResumeExperienceBullet { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int ResumeID { get; set; } // FK public int ResumeExperienceID { get; set; } // FK public string JobFunction { get; set; } = ""; } public class ResumeMilitary { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int ResumeID { get; set; } // FK public string Country { get; set; } = ""; // 2 Letter Country Code public string Rank { get; set; } = ""; @@ -55,7 +55,7 @@ namespace BoredCareers.Entities { } public class ResumeMilitaryBullet { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int ResumeID { get; set; } // FK public int ResumeMilitaryID { get; set; } // FK public string Achievement { get; set; } = ""; @@ -63,7 +63,7 @@ namespace BoredCareers.Entities { } public class ResumeEducation { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int ResumeID { get; set; } // FK public string DegreeType { get; set; } = ""; public string DegreeField { get; set; } = ""; @@ -78,21 +78,21 @@ namespace BoredCareers.Entities { } public class ResumeSkill { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int ResumeID { get; set; } // FK public string Name { get; set; } = ""; public string Description { get; set; } = ""; } public class ResumeLanguage { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int ResumeID { get; set; } // FK public string Language { get; set; } = ""; public string Proficiency { get; set; } = ""; } public class ResumeCertification { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int ResumeID { get; set; } // FK public string Name { get; set; } = ""; public string VerificationURL { get; set; } = ""; @@ -100,7 +100,7 @@ namespace BoredCareers.Entities { } public class ResumeProject { - public int ID { get; set; } // PK + public int? ID { get; set; } // PK public int ResumeID { get; set; } // FK public string Name { get; set; } = ""; public string URL { get; set; } = ""; From f3a0611b1dfadea4a55e8b8e38fb5a3c08e21fca Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Wed, 30 Jul 2025 22:01:15 -0700 Subject: [PATCH 2/3] Work around nullable ints --- src/Client/src/app/pages/main/company/company.component.html | 2 +- .../src/app/pages/main/company/jobs/jobs.component.html | 2 +- .../src/app/pages/main/jobs/editor/jobeditor.component.ts | 2 +- src/Server/Controllers/CompanyController.cs | 4 ++-- src/Server/Controllers/EmployeeController.cs | 4 ++-- src/Server/Services/DatabaseService/Resume.cs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Client/src/app/pages/main/company/company.component.html b/src/Client/src/app/pages/main/company/company.component.html index f2be310..54ca043 100644 --- a/src/Client/src/app/pages/main/company/company.component.html +++ b/src/Client/src/app/pages/main/company/company.component.html @@ -1,5 +1,5 @@
- +
diff --git a/src/Client/src/app/pages/main/company/jobs/jobs.component.html b/src/Client/src/app/pages/main/company/jobs/jobs.component.html index 70552be..db11b14 100644 --- a/src/Client/src/app/pages/main/company/jobs/jobs.component.html +++ b/src/Client/src/app/pages/main/company/jobs/jobs.component.html @@ -18,6 +18,6 @@

Modified: {{ cur.modifiedTime }}

- + \ No newline at end of file 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 bd69aad..63b61bc 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 @@ -71,7 +71,7 @@ export class JobEditorComponent { } PostJobListing(jobListing: JobListing){ - jobListing.companyID = this.selectedCompany.id; + jobListing.companyID = this.selectedCompany.id!; this.http.post("api/joblisting", jobListing).subscribe({ next: data => { this.router.navigate([""]); diff --git a/src/Server/Controllers/CompanyController.cs b/src/Server/Controllers/CompanyController.cs index 639725f..c546bf8 100644 --- a/src/Server/Controllers/CompanyController.cs +++ b/src/Server/Controllers/CompanyController.cs @@ -26,7 +26,7 @@ namespace BoredCareers.Controllers { public async Task SetCompany([FromBody] Company company, [FromQuery] bool newCompany = false) { if (isLoggedIn()) { if (newCompany) { - Company? test = await _databaseService.GetCompany(company.ID); + Company? test = await _databaseService.GetCompany(Convert.ToInt32(company.ID)); if (test == null) { company.ID = await _databaseService.SetCompany(company); await _databaseService.SetEmployee(new Employee() { @@ -37,7 +37,7 @@ namespace BoredCareers.Controllers { } return NotFound("The company already exists"); } else { - if (await isLoggedInUserEmployeeOf(company.ID)) { + if (await isLoggedInUserEmployeeOf(Convert.ToInt32(company.ID))) { await _databaseService.SetCompany(company); return Ok(); } diff --git a/src/Server/Controllers/EmployeeController.cs b/src/Server/Controllers/EmployeeController.cs index b00d61a..9a270b2 100644 --- a/src/Server/Controllers/EmployeeController.cs +++ b/src/Server/Controllers/EmployeeController.cs @@ -34,7 +34,7 @@ namespace BoredCareers.Controllers { [HttpPost] public async Task SetEmployee([FromBody] Employee employee) { if (isLoggedIn()) { - if (await isLoggedInUserEmployeeOf(employee.Company.ID)) { + if (await isLoggedInUserEmployeeOf(Convert.ToInt32(employee.Company.ID))) { await _databaseService.SetEmployee(employee); return Ok(); } @@ -48,7 +48,7 @@ namespace BoredCareers.Controllers { if (isLoggedIn()) { Employee? employee = await _databaseService.GetEmployee(EmployeeID); if (employee != null) { - if (await isLoggedInUserEmployeeOf(employee.Company.ID)) { + if (await isLoggedInUserEmployeeOf(Convert.ToInt32(employee.Company.ID))) { await _databaseService.DeleteEmployee(EmployeeID); return Ok(); } diff --git a/src/Server/Services/DatabaseService/Resume.cs b/src/Server/Services/DatabaseService/Resume.cs index 5050a10..88ff4d2 100644 --- a/src/Server/Services/DatabaseService/Resume.cs +++ b/src/Server/Services/DatabaseService/Resume.cs @@ -143,7 +143,7 @@ namespace BoredCareers.Services.DatabaseService { // Split into grouped lists and add to experience Dictionary groupedExperienceBullets = experienceBullets.GroupBy(b => b.ResumeExperienceID).ToDictionary(g => g.Key, g => g.ToArray()); foreach (ResumeExperience cur in experience) { - cur.ExperienceBullets = groupedExperienceBullets[cur.ID]; + cur.ExperienceBullets = groupedExperienceBullets[Convert.ToInt32(cur.ID)]; } // Add the parts to the resume From 9677e0f967b1350f8e0976caa736b0b7ed9b2e0c Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Wed, 30 Jul 2025 22:01:21 -0700 Subject: [PATCH 3/3] update todo --- ToDo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ToDo.yaml b/ToDo.yaml index 5c36760..8b9c668 100755 --- a/ToDo.yaml +++ b/ToDo.yaml @@ -43,4 +43,4 @@ Task: Jobs/editor w/ Querystring JobID=# is not implimented yet Company -> Edit employees not implimented yet - Remove Account table from DB \ No newline at end of file + Resume fields in angular models need to be public \ No newline at end of file