working #28

Merged
derek merged 8 commits from working into main 2025-08-14 21:51:05 -07:00
10 changed files with 735 additions and 643 deletions
+5
View File
@@ -24,6 +24,9 @@ Server:
Server.csproj: Server.csproj:
Find a way to keep all the libraries up to date Find a way to keep all the libraries up to date
DbDriver:
Make getConnection() -> Based on a connection pool so that more than a specific number of connections cannot be made
Client: Client:
jobs/editor: jobs/editor:
Job Listing Skills exists but isn't implimented in the UI Job Listing Skills exists but isn't implimented in the UI
@@ -50,6 +53,8 @@ Client:
resume/editor: resume/editor:
Not fully tested yet Not fully tested yet
When adding new fields the fields above it glitch out and disappear
There is no data validation
Company: Company:
Need to impliment Add employee Need to impliment Add employee
-1
View File
@@ -48,7 +48,6 @@ CREATE TABLE IF NOT EXISTS `Resume` (
CREATE TABLE IF NOT EXISTS `ResumeMilitary` ( CREATE TABLE IF NOT EXISTS `ResumeMilitary` (
`ID` int NOT NULL AUTO_INCREMENT, `ID` int NOT NULL AUTO_INCREMENT,
`ResumeID` int NOT NULL, `ResumeID` int NOT NULL,
`Veteran` boolean DEFAULT 0,
`Country` char(2) NOT NULL, `Country` char(2) NOT NULL,
`Rank` varchar(50) NOT NULL, `Rank` varchar(50) NOT NULL,
`DateStarted` date NOT NULL, `DateStarted` date NOT NULL,
+5 -6
View File
@@ -13,12 +13,12 @@ export class Resume {
public stateOrRegion: string = ""; public stateOrRegion: string = "";
public city: string = ""; public city: string = "";
public isActive: boolean = false; public isActive: boolean = false;
public experience: ResumeExperience[] = []; public military: ResumeMilitary | null = null;
public military: ResumeMilitary = new ResumeMilitary; public experiences: ResumeExperience[] = [];
public education: ResumeEducation[] = []; public educations: ResumeEducation[] = [];
public skills: ResumeSkill[] = []; public skills: ResumeSkill[] = [];
public languages: ResumeLanguage[] = []; public languages: ResumeLanguage[] = [];
public certification: ResumeCertification[] = []; public certifications: ResumeCertification[] = [];
public projects: ResumeProject[] = []; public projects: ResumeProject[] = [];
public trackUUID: string = crypto.randomUUID(); public trackUUID: string = crypto.randomUUID();
} }
@@ -53,13 +53,12 @@ export class ResumeMilitary {
public id: number | null = null; public id: number | null = null;
public resumeID: number | null = null; public resumeID: number | null = null;
public veteran: boolean = false;
public country: string = ""; public country: string = "";
public rank: string = ""; public rank: string = "";
public dateStarted: Date = new Date(); public dateStarted: Date = new Date();
public stillServing: boolean = false; public stillServing: boolean = false;
public dateEnded: Date = new Date(); public dateEnded: Date = new Date();
public millitaryBullets: ResumeMilitaryBullet[] = []; public militaryBullets: ResumeMilitaryBullet[] = [];
public trackUUID: string = crypto.randomUUID(); public trackUUID: string = crypto.randomUUID();
} }
@@ -2,37 +2,38 @@
<!-- Resume Header --> <!-- Resume Header -->
<div class="resume-section"> <div class="resume-section">
<input name="resumetitle" [(ngModel)]="resume.title" type="text" placeholder="Resume 1" /> <input [name]="'resumetitle' + resume.trackUUID" [(ngModel)]="resume.title" type="text" placeholder="Resume 1" />
<input name="resumename" [(ngModel)]="resume.name" type="text" placeholder="John Doe" /> <input [name]="'resumename' + resume.trackUUID" [(ngModel)]="resume.name" type="text" placeholder="John Doe" />
<input name="resumefield" [(ngModel)]="resume.field" type="text" placeholder="Data Scientist" /> <input [name]="'resumefield' + resume.trackUUID" [(ngModel)]="resume.field" type="text" placeholder="Data Scientist" />
<input name="resumeemail" [(ngModel)]="resume.email" type="email" placeholder="no-reply@mistox.com" /> <input [name]="'resumeemail' + resume.trackUUID" [(ngModel)]="resume.email" type="email" placeholder="no-reply@mistox.com" />
<input name="resumephoneNumber" [(ngModel)]="resume.phoneNumber" type="tel" placeholder="+1 800-000-0000" /> <input [name]="'resumephoneNumber' + resume.trackUUID" [(ngModel)]="resume.phoneNumber" type="tel" placeholder="+1 800-000-0000" />
<input name="resumepostalCode" [(ngModel)]="resume.postalCode" type="text" placeholder="92020" /> <input [name]="'resumepostalCode' + resume.trackUUID" [(ngModel)]="resume.postalCode" type="text" placeholder="92020" />
<input name="resumestateOrRegion" [(ngModel)]="resume.stateOrRegion" type="text" placeholder="CA" /> <input [name]="'resumecountry' + resume.trackUUID" [(ngModel)]="resume.country" type="text" placeholder="US" />
<input name="resumecity" [(ngModel)]="resume.city" type="text" placeholder="San Diego" /> <input [name]="'resumestateOrRegion' + resume.trackUUID" [(ngModel)]="resume.stateOrRegion" type="text" placeholder="CA" />
<h1>Public: </h1><input name="active" [(ngModel)]="resume.isActive" type="checkbox" /> <input [name]="'resumecity' + resume.trackUUID" [(ngModel)]="resume.city" type="text" placeholder="San Diego" />
<h1>Public: </h1><input [name]="'active' + resume.trackUUID" [(ngModel)]="resume.isActive" type="checkbox" />
</div> </div>
<!-- Experience --> <!-- Experience -->
<div class="resume-section"> <div class="resume-section">
<button type="button" (click)="addExperience()">ADD Experience</button> <button type="button" (click)="addExperience()">ADD Experience</button>
@for(experience of resume.experience; track experience.trackUUID ){ @for(experience of resume.experiences; track experience.trackUUID ){
<div class="resume-sub-section"> <div class="resume-sub-section">
<input name="experiencejobTitle" [(ngModel)]="experience.jobTitle" type="text" placeholder="Data Entry Clerk" /> <input [name]="'experiencejobTitle' + experience.trackUUID" [(ngModel)]="experience.jobTitle" type="text" placeholder="Data Entry Clerk" />
<input name="experiencecompany" [(ngModel)]="experience.company" type="text" placeholder="San Diego Gas Electric" /> <input [name]="'experiencecompany' + experience.trackUUID" [(ngModel)]="experience.company" type="text" placeholder="San Diego Gas Electric" />
<input name="experiencepostalCode" [(ngModel)]="experience.postalCode" type="text" placeholder="92020" /> <input [name]="'experiencepostalCode' + experience.trackUUID" [(ngModel)]="experience.postalCode" type="text" placeholder="92020" />
<input name="experiencecountry" [(ngModel)]="experience.country" type="text" placeholder="US" /> <input [name]="'experiencecountry' + experience.trackUUID" [(ngModel)]="experience.country" type="text" placeholder="US" />
<input name="experiencestateOrRegion" [(ngModel)]="experience.stateOrRegion" type="text" placeholder="CA" /> <input [name]="'experiencestateOrRegion' + experience.trackUUID" [(ngModel)]="experience.stateOrRegion" type="text" placeholder="CA" />
<input name="experiencecity" [(ngModel)]="experience.city" type="text" placeholder="San Diego" /> <input [name]="'experiencecity' + experience.trackUUID" [(ngModel)]="experience.city" type="text" placeholder="San Diego" />
<input name="experiencedateStarted" [(ngModel)]="experience.dateStarted" type="date" /> <input [name]="'experiencedateStarted' + experience.trackUUID" [(ngModel)]="experience.dateStarted" type="date" />
<input name="experiencestillEmployed" [(ngModel)]="experience.stillEmployed" type="checkbox" /> <input [name]="'experiencestillEmployed' + experience.trackUUID" [(ngModel)]="experience.stillEmployed" type="checkbox" />
@if(!experience.stillEmployed){ @if(!experience.stillEmployed){
<input name="experiencedateEnded" [(ngModel)]="experience.dateEnded" type="date" /> <input [name]="'experiencedateEnded' + experience.trackUUID" [(ngModel)]="experience.dateEnded" type="date" />
} }
<button type="button" (click)="addJobFunction(experience)">Add jobFunction</button> <button type="button" (click)="addJobFunction(experience)">Add jobFunction</button>
@for(bullet of experience.experienceBullets; track bullet.trackUUID){ @for(bullet of experience.experienceBullets; track bullet.trackUUID){
<div> <div>
<textarea name="bulletjobFunction" [(ngModel)]="bullet.jobFunction" placeholder="Processed database transactions" ></textarea> <textarea [name]="'bulletjobFunction' + bullet.trackUUID" [(ngModel)]="bullet.jobFunction" placeholder="Processed database transactions" ></textarea>
<button type="button" (click)="delJobFunction(experience, bullet)">DEL jobFunction</button> <button type="button" (click)="delJobFunction(experience, bullet)">DEL jobFunction</button>
</div> </div>
} }
@@ -43,20 +44,20 @@
<!-- Military --> <!-- Military -->
<div class="resume-section"> <div class="resume-section">
<h1>Is Veteran: </h1><input name="veteran" [(ngModel)]="resume.military.veteran" type="checkbox" /> <h1>Is Veteran: </h1><input [name]="'veteran' + resume.military?.trackUUID" type="checkbox" (change)="onVeteranChange($event)" />
@if(resume.military.veteran){ @if(resume.military !== null){
<input name="militarycountry" [(ngModel)]="resume.military.country" type="text" placeholder="US" /> <input [name]="'militarycountry' + resume.military.trackUUID" [(ngModel)]="resume.military.country" type="text" placeholder="US" />
<input name="militaryrank" [(ngModel)]="resume.military.rank" type="text" placeholder="PVT" /> <input [name]="'militaryrank' + resume.military.trackUUID" [(ngModel)]="resume.military.rank" type="text" placeholder="PVT" />
<input name="militarydateStarted" [(ngModel)]="resume.military.dateStarted" type="date" /> <input [name]="'militarydateStarted' + resume.military.trackUUID" [(ngModel)]="resume.military.dateStarted" type="date" />
<h1>Still Serving: </h1><input name="stillServing" [(ngModel)]="resume.military.stillServing" type="checkbox" /> <h1>Still Serving: </h1><input [name]="'stillServing' + resume.military.trackUUID" [(ngModel)]="resume.military.stillServing" type="checkbox" />
@if (!resume.military.stillServing){ @if (!resume.military.stillServing){
<input name="dateEnded" [(ngModel)]="resume.military.dateEnded" type="date" /> <input [name]="'dateEnded' + resume.military.trackUUID" [(ngModel)]="resume.military.dateEnded" type="date" />
} }
<button type="button" (click)="addMillitaryBullet()">Add Millitary Task</button> <button type="button" (click)="addMillitaryBullet()">Add Millitary Task</button>
@for(military of resume.military.millitaryBullets; track military.trackUUID ){ @for(military of resume.military.militaryBullets; track military.trackUUID ){
<div> <div>
<input name="militaryachievement" [(ngModel)]="military.achievement" type="text" placeholder="Deployed Kuwait" /> <input [name]="'militaryachievement' + military.trackUUID" [(ngModel)]="military.achievement" type="text" placeholder="Deployed Kuwait" />
<textarea name="militarydescription" [(ngModel)]="military.description" placeholder="Delivered goods line-hall" ></textarea> <textarea [name]="'militarydescription' + military.trackUUID" [(ngModel)]="military.description" placeholder="Delivered goods line-hall" ></textarea>
<button type="button" (click)="delMillitaryBullet(military)">DEL Military Task</button> <button type="button" (click)="delMillitaryBullet(military)">DEL Military Task</button>
</div> </div>
} }
@@ -66,19 +67,19 @@
<!-- Education --> <!-- Education -->
<div class="resume-section"> <div class="resume-section">
<button type="button" (click)="addEducation()">ADD Education</button> <button type="button" (click)="addEducation()">ADD Education</button>
@for(education of resume.education; track education.trackUUID){ @for(education of resume.educations; track education.trackUUID){
<div> <div>
<input name="educationdegreeType" [(ngModel)]="education.degreeType" type="text" placeholder="Masters" /> <input [name]="'educationdegreeType' + education.trackUUID" [(ngModel)]="education.degreeType" type="text" placeholder="Masters" />
<input name="educationdegreeField" [(ngModel)]="education.degreeField" type="text" placeholder="Computer Science" /> <input [name]="'educationdegreeField' + education.trackUUID" [(ngModel)]="education.degreeField" type="text" placeholder="Computer Science" />
<input name="educationschool" [(ngModel)]="education.school" type="text" placeholder="WGU" /> <input [name]="'educationschool' + education.trackUUID" [(ngModel)]="education.school" type="text" placeholder="WGU" />
<input name="educationpostalCode" [(ngModel)]="education.postalCode" type="text" placeholder="84107" /> <input [name]="'educationpostalCode' + education.trackUUID" [(ngModel)]="education.postalCode" type="text" placeholder="84107" />
<input name="educationcountry" [(ngModel)]="education.country" type="text" placeholder="US" /> <input [name]="'educationcountry' + education.trackUUID" [(ngModel)]="education.country" type="text" placeholder="US" />
<input name="educationstateOrRegion" [(ngModel)]="education.stateOrRegion" type="text" placeholder="UT" /> <input [name]="'educationstateOrRegion' + education.trackUUID" [(ngModel)]="education.stateOrRegion" type="text" placeholder="UT" />
<input name="educationcity" [(ngModel)]="education.city" type="text" placeholder="Salt Lake City" /> <input [name]="'educationcity' + education.trackUUID" [(ngModel)]="education.city" type="text" placeholder="Salt Lake City" />
<input name="educationdateStarted" [(ngModel)]="education.dateStarted" type="date" /> <input [name]="'educationdateStarted' + education.trackUUID" [(ngModel)]="education.dateStarted" type="date" />
<input name="educationstillStudying" [(ngModel)]="education.stillStudying" type="checkbox" /> <input [name]="'educationstillStudying' + education.trackUUID" [(ngModel)]="education.stillStudying" type="checkbox" />
@if (!education.stillStudying){ @if (!education.stillStudying){
<input name="educationdateEnded" [(ngModel)]="education.dateEnded" type="date" /> <input [name]="'educationdateEnded' + education.trackUUID" [(ngModel)]="education.dateEnded" type="date" />
} }
<button type="button" (click)="delEducation(education)">DEL Education</button> <button type="button" (click)="delEducation(education)">DEL Education</button>
</div> </div>
@@ -90,8 +91,8 @@
<button type="button" (click)="addSkill()">ADD Skill</button> <button type="button" (click)="addSkill()">ADD Skill</button>
@for(skill of resume.skills; track skill.trackUUID){ @for(skill of resume.skills; track skill.trackUUID){
<div> <div>
<input name="skillname" [(ngModel)]="skill.name" type="text" placeholder="Angular JS" /> <input [name]="'skillname' + skill.trackUUID" [(ngModel)]="skill.name" type="text" placeholder="Angular JS" />
<textarea name="skilldescription" [(ngModel)]="skill.description" placeholder="Built this entire website using Angular JS"></textarea> <textarea [name]="'skilldescription' + skill.trackUUID" [(ngModel)]="skill.description" placeholder="Built this entire website using Angular JS"></textarea>
<button type="button" (click)="delSkill(skill)">DEL Skill</button> <button type="button" (click)="delSkill(skill)">DEL Skill</button>
</div> </div>
} }
@@ -102,8 +103,8 @@
<button type="button" (click)="addLanguage()">ADD Language</button> <button type="button" (click)="addLanguage()">ADD Language</button>
@for(language of resume.languages; track language.trackUUID){ @for(language of resume.languages; track language.trackUUID){
<div> <div>
<input name="languagelanguage" [(ngModel)]="language.language" type="text" placeholder="Spanish" /> <input [name]="'languagelanguage' + language.trackUUID" [(ngModel)]="language.language" type="text" placeholder="Spanish" />
<input name="languageproficiency" [(ngModel)]="language.proficiency" type="text" placeholder="casual speaking" /> <input [name]="'languageproficiency' + language.trackUUID" [(ngModel)]="language.proficiency" type="text" placeholder="casual speaking" />
<button type="button" (click)="delLanguage(language)">DEL Language</button> <button type="button" (click)="delLanguage(language)">DEL Language</button>
</div> </div>
} }
@@ -113,11 +114,11 @@
<!-- Certification --> <!-- Certification -->
<div class="resume-section"> <div class="resume-section">
<button type="button" (click)="addCert()">ADD Certification</button> <button type="button" (click)="addCert()">ADD Certification</button>
@for(cert of resume.certification; track cert.trackUUID){ @for(cert of resume.certifications; track cert.trackUUID){
<div> <div>
<input name="certname" [(ngModel)]="cert.name" type="text" placeholder="Comptia A+" /> <input [name]="'certname' + cert.trackUUID" [(ngModel)]="cert.name" type="text" placeholder="Comptia A+" />
<input name="certverificationURL" [(ngModel)]="cert.verificationURL" type="text" placeholder="https://certmaster.com/certid" /> <input [name]="'certverificationURL' + cert.trackUUID" [(ngModel)]="cert.verificationURL" type="text" placeholder="https://certmaster.com/certid" />
<textarea name="certdescription" [(ngModel)]="cert.description" placeholder="Into to information technology"></textarea> <textarea [name]="'certdescription' + cert.trackUUID" [(ngModel)]="cert.description" placeholder="Into to information technology"></textarea>
<button type="button" (click)="delCert(cert)">DEL Certification</button> <button type="button" (click)="delCert(cert)">DEL Certification</button>
</div> </div>
} }
@@ -128,9 +129,9 @@
<button type="button" (click)="addProject()">ADD Project</button> <button type="button" (click)="addProject()">ADD Project</button>
@for(proj of resume.projects; track proj.trackUUID){ @for(proj of resume.projects; track proj.trackUUID){
<div> <div>
<input name="projname" [(ngModel)]="proj.name" type="text" placeholder="boredcareers" /> <input [name]="'projname' + proj.trackUUID" [(ngModel)]="proj.name" type="text" placeholder="boredcareers" />
<input name="projurl" [(ngModel)]="proj.url" type="text" placeholder="mistox.com" /> <input [name]="'projurl' + proj.trackUUID" [(ngModel)]="proj.url" type="text" placeholder="mistox.com" />
<textarea name="projdescription" [(ngModel)]="proj.description" placeholder="the project that your currently viewing"></textarea> <textarea [name]="'projdescription' + proj.trackUUID" [(ngModel)]="proj.description" placeholder="the project that your currently viewing"></textarea>
<button type="button" (click)="delProject(proj)">DEL Project</button> <button type="button" (click)="delProject(proj)">DEL Project</button>
</div> </div>
} }
@@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms';
import { Router, ActivatedRoute, RouterModule } from '@angular/router'; 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 { Resume, ResumeCertification, ResumeEducation, ResumeExperience, ResumeExperienceBullet, ResumeLanguage, ResumeMilitaryBullet, ResumeProject, ResumeSkill } from 'app/models/Resume'; import { Resume, ResumeCertification, ResumeEducation, ResumeExperience, ResumeExperienceBullet, ResumeLanguage, ResumeMilitary, ResumeMilitaryBullet, ResumeProject, ResumeSkill } from 'app/models/Resume';
import { Authentication } from 'app/services/Authentication'; import { Authentication } from 'app/services/Authentication';
import { HomeComponent } from "app/pages/home/home.component"; import { HomeComponent } from "app/pages/home/home.component";
@@ -33,6 +33,7 @@ export class ResumesEditorComponent {
this.http.get<Resume>("api/resume?ResumeID=" + ResumeID).subscribe({ this.http.get<Resume>("api/resume?ResumeID=" + ResumeID).subscribe({
next: data => { next: data => {
this.resume = data; this.resume = data;
this.milCache = data.military;
this.isNewResume = false; this.isNewResume = false;
}, },
error: err => { error: err => {
@@ -56,13 +57,13 @@ export class ResumesEditorComponent {
} }
addExperience(){ addExperience(){
this.resume.experience.push( new ResumeExperience ); this.resume.experiences.push( new ResumeExperience );
} }
delExperience(self: ResumeExperience){ delExperience(self: ResumeExperience){
for(let i=0; i<this.resume.experience.length; i++){ for(let i=0; i<this.resume.experiences.length; i++){
let cur = this.resume.experience[i]; let cur = this.resume.experiences[i];
if (cur.trackUUID === self.trackUUID){ if (cur.trackUUID === self.trackUUID){
this.resume.experience.splice( i, 1 ); this.resume.experiences.splice( i, 1 );
break; break;
} }
} }
@@ -81,27 +82,39 @@ export class ResumesEditorComponent {
} }
} }
milCache: ResumeMilitary | null = new ResumeMilitary;
onVeteranChange(event: Event){
const checkbox = event.target as HTMLInputElement;
const isChecked = checkbox.checked;
if (isChecked){
this.resume.military = this.milCache;
} else {
this.resume.military = null;
}
}
addMillitaryBullet(){ addMillitaryBullet(){
this.resume.military.millitaryBullets.push( new ResumeMilitaryBullet ); this.resume.military?.militaryBullets.push( new ResumeMilitaryBullet );
} }
delMillitaryBullet(self: ResumeMilitaryBullet){ delMillitaryBullet(self: ResumeMilitaryBullet){
for(let i=0; i<this.resume.military.millitaryBullets.length; i++){ if (this.resume.military !== null){
let cur = this.resume.military.millitaryBullets[i]; for(let i=0; i<this.resume.military.militaryBullets.length; i++){
let cur = this.resume.military.militaryBullets[i];
if (cur.trackUUID === self.trackUUID){ if (cur.trackUUID === self.trackUUID){
this.resume.military.millitaryBullets.splice( i, 1 ); this.resume.military.militaryBullets.splice( i, 1 );
break; break;
} }
} }
} }
}
addEducation(){ addEducation(){
this.resume.education.push( new ResumeEducation ); this.resume.educations.push( new ResumeEducation );
} }
delEducation(self: ResumeEducation){ delEducation(self: ResumeEducation){
for(let i=0; i<this.resume.education.length; i++){ for(let i=0; i<this.resume.educations.length; i++){
let cur = this.resume.education[i]; let cur = this.resume.educations[i];
if (cur.trackUUID === self.trackUUID){ if (cur.trackUUID === self.trackUUID){
this.resume.education.splice( i, 1 ); this.resume.educations.splice( i, 1 );
break; break;
} }
} }
@@ -134,13 +147,13 @@ export class ResumesEditorComponent {
} }
addCert(){ addCert(){
this.resume.certification.push( new ResumeCertification ); this.resume.certifications.push( new ResumeCertification );
} }
delCert(self: ResumeCertification){ delCert(self: ResumeCertification){
for(let i=0; i<this.resume.certification.length; i++){ for(let i=0; i<this.resume.certifications.length; i++){
let cur = this.resume.certification[i]; let cur = this.resume.certifications[i];
if (cur.trackUUID === self.trackUUID){ if (cur.trackUUID === self.trackUUID){
this.resume.certification.splice( i, 1 ); this.resume.certifications.splice( i, 1 );
break; break;
} }
} }
@@ -1,6 +1,8 @@
<div class="top-bar"> <div class="top-bar">
@for(resume of myResumes; track myResumes.length){ @for(resume of myResumes; track myResumes.length){
<button (click)="changeSelectedResume(5)">{{ resume.title }}</button> @if (resume.id != null){
<button (click)="changeSelectedResume(resume.id)">{{ resume.title }}</button>
}
} }
<button routerLink="/resumes/editor" >NEW RESUME</button> <button routerLink="/resumes/editor" >NEW RESUME</button>
</div> </div>
+15 -16
View File
@@ -12,18 +12,18 @@ namespace BoredCareers.Entities {
public string StateOrRegion { get; set; } = ""; public string StateOrRegion { get; set; } = "";
public string City { get; set; } = ""; public string City { get; set; } = "";
public bool IsActive { get; set; } = false; public bool IsActive { get; set; } = false;
public ResumeExperience[] Experience { get; set; } = []; public ResumeExperience[] Experiences { get; set; } = [];
public ResumeMilitary Millitary { get; set; } = new ResumeMilitary(); public ResumeMilitary? Military { get; set; } = null;
public ResumeEducation[] Educations { get; set; } = []; public ResumeEducation[] Educations { get; set; } = [];
public ResumeSkill[] Skills { get; set; } = []; public ResumeSkill[] Skills { get; set; } = [];
public ResumeLanguage[] Languages { get; set; } = []; public ResumeLanguage[] Languages { get; set; } = [];
public ResumeCertification[] Certification { get; set; } = []; public ResumeCertification[] Certifications { get; set; } = [];
public ResumeProject[] Projects { get; set; } = []; public ResumeProject[] Projects { get; set; } = [];
} }
public class ResumeExperience { public class ResumeExperience {
public int? ID { get; set; } // PK public int? ID { get; set; } // PK
public int ResumeID { get; set; } // FK public int? ResumeID { get; set; } // FK
public string JobTitle { get; set; } = ""; public string JobTitle { get; set; } = "";
public string Company { get; set; } = ""; public string Company { get; set; } = "";
public string PostalCode { get; set; } = ""; public string PostalCode { get; set; } = "";
@@ -38,34 +38,33 @@ namespace BoredCareers.Entities {
public class ResumeExperienceBullet { public class ResumeExperienceBullet {
public int? ID { get; set; } // PK public int? ID { get; set; } // PK
public int ResumeID { get; set; } // FK public int? ResumeID { get; set; } // FK
public int ResumeExperienceID { get; set; } // FK public int? ResumeExperienceID { get; set; } // FK
public string JobFunction { get; set; } = ""; public string JobFunction { get; set; } = "";
} }
public class ResumeMilitary { public class ResumeMilitary {
public int? ID { get; set; } // PK public int? ID { get; set; } // PK
public int ResumeID { get; set; } // FK public int? ResumeID { get; set; } // FK
public bool Veteran { get; set; } = false;
public string Country { get; set; } = ""; // 2 Letter Country Code public string Country { get; set; } = ""; // 2 Letter Country Code
public string Rank { get; set; } = ""; public string Rank { get; set; } = "";
public DateTime DateStarted { get; set; } = new DateTime(); public DateTime DateStarted { get; set; } = new DateTime();
public bool StillServing { get; set; } = false; public bool StillServing { get; set; } = false;
public DateTime DateEnded { get; set; } = new DateTime(); public DateTime DateEnded { get; set; } = new DateTime();
public ResumeMilitaryBullet[] MillitaryBullets = []; public ResumeMilitaryBullet[] MilitaryBullets { get; set; } = [];
} }
public class ResumeMilitaryBullet { public class ResumeMilitaryBullet {
public int? ID { get; set; } // PK public int? ID { get; set; } // PK
public int ResumeID { get; set; } // FK public int? ResumeID { get; set; } // FK
public int ResumeMilitaryID { get; set; } // FK public int? ResumeMilitaryID { get; set; } // FK
public string Achievement { get; set; } = ""; public string Achievement { get; set; } = "";
public string Description { get; set; } = ""; public string Description { get; set; } = "";
} }
public class ResumeEducation { public class ResumeEducation {
public int? ID { get; set; } // PK public int? ID { get; set; } // PK
public int ResumeID { get; set; } // FK public int? ResumeID { get; set; } // FK
public string DegreeType { get; set; } = ""; public string DegreeType { get; set; } = "";
public string DegreeField { get; set; } = ""; public string DegreeField { get; set; } = "";
public string School { get; set; } = ""; public string School { get; set; } = "";
@@ -80,21 +79,21 @@ namespace BoredCareers.Entities {
public class ResumeSkill { public class ResumeSkill {
public int? ID { get; set; } // PK public int? ID { get; set; } // PK
public int ResumeID { get; set; } // FK public int? ResumeID { get; set; } // FK
public string Name { get; set; } = ""; public string Name { get; set; } = "";
public string Description { get; set; } = ""; public string Description { get; set; } = "";
} }
public class ResumeLanguage { public class ResumeLanguage {
public int? ID { get; set; } // PK public int? ID { get; set; } // PK
public int ResumeID { get; set; } // FK public int? ResumeID { get; set; } // FK
public string Language { get; set; } = ""; public string Language { get; set; } = "";
public string Proficiency { get; set; } = ""; public string Proficiency { get; set; } = "";
} }
public class ResumeCertification { public class ResumeCertification {
public int? ID { get; set; } // PK public int? ID { get; set; } // PK
public int ResumeID { get; set; } // FK public int? ResumeID { get; set; } // FK
public string Name { get; set; } = ""; public string Name { get; set; } = "";
public string VerificationURL { get; set; } = ""; public string VerificationURL { get; set; } = "";
public string Description { get; set; } = ""; public string Description { get; set; } = "";
@@ -102,7 +101,7 @@ namespace BoredCareers.Entities {
public class ResumeProject { public class ResumeProject {
public int? ID { get; set; } // PK public int? ID { get; set; } // PK
public int ResumeID { get; set; } // FK public int? ResumeID { get; set; } // FK
public string Name { get; set; } = ""; public string Name { get; set; } = "";
public string URL { get; set; } = ""; public string URL { get; set; } = "";
public string Description { get; set; } = ""; public string Description { get; set; } = "";
+99 -137
View File
@@ -59,164 +59,126 @@ namespace BoredCareers.Services.DatabaseService {
} }
public async Task<Resume?> GetResume(int ResumeID) { public async Task<Resume?> GetResume(int ResumeID) {
// Open connections for multi-threaded request using (var conn = GetConnection()) {
MySqlConnection resumeConnection = GetConnection(); await conn.OpenAsync();
MySqlConnection ResumeExperienceConnection = GetConnection();
MySqlConnection ResumeExperienceBulletConnection = GetConnection();
MySqlConnection ResumeMilitaryConnection = GetConnection();
MySqlConnection ResumeMilitaryBulletConnection = GetConnection();
MySqlConnection ResumeEducationConnection = GetConnection();
MySqlConnection ResumeSkillConnection = GetConnection();
MySqlConnection ResumeLanguageConnection = GetConnection();
MySqlConnection ResumeCertificationConnection = GetConnection();
MySqlConnection ResumeProjectConnection = GetConnection();
// Open the connections // Check if resume header exists
Task resumeopen = resumeConnection.OpenAsync(); Resume? resume = await GetResumeHeader(ResumeID);
Task resumeexperienceopen = ResumeExperienceConnection.OpenAsync(); if (resume == null) { return null; }
Task resumeexperiencebulletopen = ResumeExperienceBulletConnection.OpenAsync();
Task resumemilitaryopen = ResumeMilitaryConnection.OpenAsync();
Task resumemilitarybulletopen = ResumeMilitaryBulletConnection.OpenAsync();
Task resumeeducationopen = ResumeEducationConnection.OpenAsync();
Task resumeskillopen = ResumeSkillConnection.OpenAsync();
Task resumelanguageopen = ResumeLanguageConnection.OpenAsync();
Task resumecertifcationopen = ResumeCertificationConnection.OpenAsync();
Task resumeprojectopen = ResumeProjectConnection.OpenAsync();
// Wait for all the connections to open // Create parallel threads
await Task.WhenAll(resumeopen, resumeexperienceopen, resumeexperiencebulletopen, resumemilitaryopen, resumemilitarybulletopen, Task<ResumeExperience[]> experienceTask = GetResumeExperience(ResumeID);
resumeeducationopen, resumeskillopen, resumelanguageopen, resumecertifcationopen, resumeprojectopen); Task<ResumeExperienceBullet[]> experienceBulletsTask = GetResumeExperienceBullets(ResumeID);
Task<ResumeMilitary?> militaryTask = GetResumeMilitary(ResumeID);
Task<ResumeMilitaryBullet[]> militaryBulletsTask = GetResumeMilitaryBullets(ResumeID);
Task<ResumeEducation[]> educationTask = GetResumeEducation(ResumeID);
Task<ResumeSkill[]> skillsTask = GetResumeSkills(ResumeID);
Task<ResumeLanguage[]> languagesTask = GetResumeLanguages(ResumeID);
Task<ResumeCertification[]> certificationTask = GetResumeCertification(ResumeID);
Task<ResumeProject[]> projectsTask = GetResumeProjects(ResumeID);
// Setup the commands for the connections // Run all in parallel
MySqlCommand resumeCommand = new MySqlCommand("SELECT * FROM Resume WHERE ID = @ResumeID;", resumeConnection); await Task.WhenAll(
MySqlCommand ResumeExperienceCommand = new MySqlCommand("SELECT * FROM ResumeExperience WHERE ResumeID = @ResumeID;", ResumeExperienceConnection); experienceTask,
MySqlCommand ResumeExperienceBulletCommand = new MySqlCommand("SELECT * FROM ResumeExperienceBullet WHERE ResumeID = @ResumeID;", ResumeExperienceBulletConnection); experienceBulletsTask,
MySqlCommand ResumeMilitaryCommand = new MySqlCommand("SELECT * FROM ResumeMilitary WHERE ResumeID = @ResumeID;", ResumeMilitaryConnection); militaryTask,
MySqlCommand ResumeMilitaryBulletCommand = new MySqlCommand("SELECT * FROM ResumeMilitaryBullet WHERE ResumeID = @ResumeID", ResumeMilitaryBulletConnection); militaryBulletsTask,
MySqlCommand ResumeEducationCommand = new MySqlCommand("SELECT * FROM ResumeEducation WHERE ResumeID = @ResumeID;", ResumeEducationConnection); educationTask,
MySqlCommand ResumeSkillCommand = new MySqlCommand("SELECT * FROM ResumeSkill WHERE ResumeID = @ResumeID;", ResumeSkillConnection); skillsTask,
MySqlCommand ResumeLanguageCommand = new MySqlCommand("SELECT * FROM ResumeLanguage WHERE ResumeID = @ResumeID;", ResumeLanguageConnection); languagesTask,
MySqlCommand ResumeCertificationCommand = new MySqlCommand("SELECT * FROM ResumeCertification WHERE ResumeID = @ResumeID;", ResumeCertificationConnection); certificationTask,
MySqlCommand ResumeProjectCommand = new MySqlCommand("SELECT * FROM ResumeProject WHERE ResumeID = @ResumeID;", ResumeProjectConnection); projectsTask
);
// Add parameters to the commands // Get results from parallel processes
resumeCommand.Parameters.AddWithValue("@ResumeID", ResumeID); ResumeExperience[] experience = await experienceTask;
ResumeExperienceCommand.Parameters.AddWithValue("@ResumeID", ResumeID); ResumeExperienceBullet[] bullets = await experienceBulletsTask;
ResumeExperienceBulletCommand.Parameters.AddWithValue("@ResumeID", ResumeID); ResumeMilitary? military = await militaryTask;
ResumeMilitaryCommand.Parameters.AddWithValue("@ResumeID", ResumeID); ResumeMilitaryBullet[] militaryBullets = await militaryBulletsTask;
ResumeMilitaryBulletCommand.Parameters.AddWithValue("@ResumeID", ResumeID); ResumeEducation[] education = await educationTask;
ResumeEducationCommand.Parameters.AddWithValue("@ResumeID", ResumeID); ResumeSkill[] skills = await skillsTask;
ResumeSkillCommand.Parameters.AddWithValue("@ResumeID", ResumeID); ResumeLanguage[] languages = await languagesTask;
ResumeLanguageCommand.Parameters.AddWithValue("@ResumeID", ResumeID); ResumeCertification[] certs = await certificationTask;
ResumeCertificationCommand.Parameters.AddWithValue("@ResumeID", ResumeID); ResumeProject[] projects = await projectsTask;
ResumeProjectCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
// Run the commands Dictionary<int, ResumeExperienceBullet[]> groupedExperienceBullets = bullets.GroupBy(b => Convert.ToInt32(b.ResumeExperienceID)).ToDictionary(g => g.Key, g => g.ToArray());
Task<DbDataReader> ResumeReader = resumeCommand.ExecuteReaderAsync(); foreach (var exp in experience) {
Task<DbDataReader> ResumeExperienceReader = ResumeExperienceCommand.ExecuteReaderAsync(); exp.ExperienceBullets = groupedExperienceBullets.TryGetValue(Convert.ToInt32(exp.ID), out var b) ? b : Array.Empty<ResumeExperienceBullet>();
Task<DbDataReader> ResumeExperienceBulletReader = ResumeExperienceBulletCommand.ExecuteReaderAsync();
Task<DbDataReader> ResumeMilitaryReader = ResumeMilitaryCommand.ExecuteReaderAsync();
Task<DbDataReader> ResumeMilitaryBulletReader = ResumeMilitaryBulletCommand.ExecuteReaderAsync();
Task<DbDataReader> ResumeEducationReader = ResumeEducationCommand.ExecuteReaderAsync();
Task<DbDataReader> ResumeSkillReader = ResumeSkillCommand.ExecuteReaderAsync();
Task<DbDataReader> ResumeLanguageReader = ResumeLanguageCommand.ExecuteReaderAsync();
Task<DbDataReader> ResumeCertificationReader = ResumeCertificationCommand.ExecuteReaderAsync();
Task<DbDataReader> ResumeProjectReader = ResumeProjectCommand.ExecuteReaderAsync();
// Wait for all the commands to process
await Task.WhenAll(ResumeReader, ResumeExperienceReader, ResumeExperienceBulletReader, ResumeMilitaryReader, ResumeMilitaryBulletReader,
ResumeEducationReader, ResumeSkillReader, ResumeLanguageReader, ResumeCertificationReader, ResumeProjectReader);
// Get Resume
Resume? resume = await GetResume( await ResumeReader );
if (resume != null) {
// Get Resume Parts
ResumeExperience[] experience = await GetResumeExperience(await ResumeExperienceReader);
ResumeExperienceBullet[] experienceBullets = await GetResumeExperienceBullets(await ResumeExperienceBulletReader);
ResumeMilitary? military = await GetResumeMilitary(await ResumeMilitaryReader);
ResumeMilitaryBullet[] militaryBullets = await GetResumeMilitaryBullets(await ResumeMilitaryBulletReader);
ResumeEducation[] education = await GetResumeEducation(await ResumeEducationReader);
ResumeSkill[] skills = await GetResumeSkills(await ResumeSkillReader);
ResumeLanguage[] languages = await GetResumeLanguages(await ResumeLanguageReader);
ResumeCertification[] certs = await GetResumeCertification(await ResumeCertificationReader);
ResumeProject[] projects = await GetResumeProjects(await ResumeProjectReader);
// Split into grouped lists and add to experience
Dictionary<int, ResumeExperienceBullet[]> groupedExperienceBullets = experienceBullets.GroupBy(b => b.ResumeExperienceID).ToDictionary(g => g.Key, g => g.ToArray());
foreach (ResumeExperience cur in experience) {
cur.ExperienceBullets = groupedExperienceBullets[Convert.ToInt32(cur.ID)];
} }
// Add the parts to the resume resume.Experiences = experience;
if (military != null) {
military.MillitaryBullets = militaryBullets;
resume.Millitary = military;
}
resume.Experience = experience;
resume.Educations = education; resume.Educations = education;
resume.Skills = skills; resume.Skills = skills;
resume.Languages = languages; resume.Languages = languages;
resume.Certification = certs; resume.Certifications = certs;
resume.Projects = projects; resume.Projects = projects;
if (military != null) {
military.MilitaryBullets = militaryBullets;
resume.Military = military;
}
return resume; return resume;
} }
return null;
} }
public async Task SetResume(Resume resume) { public async Task SetResume(Resume resume) {
// Set ResumeID on all nodes
// Open connections for multi-threaded request int _ResumeID = await SetResumeHeader(resume);
MySqlConnection resumeConnection = GetConnection(); if (resume.Military != null) {
MySqlConnection ResumeExperienceConnection = GetConnection(); resume.Military.ResumeID = _ResumeID;
MySqlConnection ResumeExperienceBulletConnection = GetConnection(); foreach (ResumeMilitaryBullet cur in resume.Military.MilitaryBullets) {
MySqlConnection ResumeMilitaryConnection = GetConnection(); cur.ResumeID = _ResumeID;
MySqlConnection ResumeMilitaryBulletConnection = GetConnection(); }
MySqlConnection ResumeEducationConnection = GetConnection(); }
MySqlConnection ResumeSkillConnection = GetConnection(); foreach (ResumeEducation cur in resume.Educations) { cur.ResumeID = _ResumeID; }
MySqlConnection ResumeLanguageConnection = GetConnection(); foreach (ResumeSkill cur in resume.Skills) { cur.ResumeID = _ResumeID; }
MySqlConnection ResumeCertificationConnection = GetConnection(); foreach (ResumeLanguage cur in resume.Languages) { cur.ResumeID = _ResumeID; }
MySqlConnection ResumeProjectConnection = GetConnection(); foreach (ResumeCertification cur in resume.Certifications) { cur.ResumeID = _ResumeID; }
foreach (ResumeProject cur in resume.Projects) { cur.ResumeID = _ResumeID; }
// Open the connections foreach (ResumeExperience cur in resume.Experiences) {
Task resumeopen = resumeConnection.OpenAsync(); cur.ResumeID = _ResumeID;
Task resumeexperienceopen = ResumeExperienceConnection.OpenAsync(); foreach (ResumeExperienceBullet us in cur.ExperienceBullets) {
Task resumeexperiencebulletopen = ResumeExperienceBulletConnection.OpenAsync(); us.ResumeID = _ResumeID;
Task resumemilitaryopen = ResumeMilitaryConnection.OpenAsync();
Task resumemilitarybulletopen = ResumeMilitaryBulletConnection.OpenAsync();
Task resumeeducationopen = ResumeEducationConnection.OpenAsync();
Task resumeskillopen = ResumeSkillConnection.OpenAsync();
Task resumelanguageopen = ResumeLanguageConnection.OpenAsync();
Task resumecertifcationopen = ResumeCertificationConnection.OpenAsync();
Task resumeprojectopen = ResumeProjectConnection.OpenAsync();
// Wait for all the connections to open
await Task.WhenAll(resumeopen, resumeexperienceopen, resumeexperiencebulletopen, resumemilitaryopen, resumemilitarybulletopen,
resumeeducationopen, resumeskillopen, resumelanguageopen, resumecertifcationopen, resumeprojectopen);
// Get all the experience bullets and run all the updates
List<ResumeExperienceBullet> bullets = new List<ResumeExperienceBullet>();
foreach (ResumeExperience cur in resume.Experience) {
foreach (ResumeExperienceBullet bullet in cur.ExperienceBullets) {
bullets.Add(bullet);
} }
} }
Task ResumeExperienceBulletTask = SetResumeExperienceBullets(ResumeExperienceBulletConnection, bullets.ToArray());
Task ResumeTask = SetResume(resumeConnection, resume);
Task ResumeExperienceTask = SetResumeExperience(ResumeExperienceConnection, resume.Experience);
Task ResumeMilitaryTask = SetResumeMilitary(ResumeMilitaryConnection, resume.Millitary);
Task ResumeMilitaryBulletTask = SetResumeMilitaryBullets(ResumeMilitaryBulletConnection, resume.Millitary.MillitaryBullets);
Task ResumeEducationTask = SetResumeEducation(ResumeEducationConnection, resume.Educations);
Task ResumeSkllTask = SetResumeSkills(ResumeSkillConnection, resume.Skills);
Task ResumeLanguageTask = SetResumeLanguages(ResumeLanguageConnection, resume.Languages);
Task ResumeCertTask = SetResumeCertification(ResumeCertificationConnection, resume.Certification);
Task ResumeProjectTask = SetResumeProjects(ResumeProjectConnection, resume.Projects);
// Allow update to finish before closing process // Async process all non child node SQL sets
await Task.WhenAll(ResumeTask, ResumeExperienceTask, ResumeExperienceBulletTask, ResumeMilitaryTask, ResumeMilitaryBulletTask, Task[] tasks = [
ResumeEducationTask, ResumeSkllTask, ResumeLanguageTask, ResumeCertTask, ResumeProjectTask); SetResumeEducation(resume.Educations),
SetResumeSkills(resume.Skills),
SetResumeLanguages(resume.Languages),
SetResumeCertification(resume.Certifications),
SetResumeProjects(resume.Projects)
];
await Task.WhenAll(tasks);
// Setup military task
if (resume.Military != null) {
ResumeMilitary militaryTask = await SetResumeMilitary(resume.Military);
foreach (ResumeMilitaryBullet cur in resume.Military.MilitaryBullets) {
cur.ResumeMilitaryID = Convert.ToInt32(militaryTask.ID);
}
await SetResumeMilitaryBullets(resume.Military.MilitaryBullets);
}
// Setup async process all experience tasks
List<Task<ResumeExperience>> experienceTasks = new List<Task<ResumeExperience>>();
foreach (ResumeExperience cur in resume.Experiences) {
experienceTasks.Add(SetResumeExperience(cur));
}
await Task.WhenAll(experienceTasks);
// Assuming they are returned in the same order they are sent
List<Task> experienceBulletTasks = new List<Task>();
for (int i = 0; i < experienceTasks.Count; i++) {
ResumeExperience self = await experienceTasks[i];
foreach (ResumeExperienceBullet cur in resume.Experiences[i].ExperienceBullets) {
cur.ResumeExperienceID = Convert.ToInt32(self.ID);
experienceBulletTasks.Add(SetResumeExperienceBullets(cur));
}
}
await Task.WhenAll(experienceBulletTasks);
} }
public async Task DeleteResume( int ResumeID ) { public async Task DeleteResume( int ResumeID ) {
@@ -1,24 +1,33 @@
using BoredCareers.Entities; using BoredCareers.Entities;
using MySql.Data.MySqlClient;
using System.Data; using System.Data;
using System.Data.Common; using System.Data.Common;
namespace BoredCareers.Services.DatabaseService { namespace BoredCareers.Services.DatabaseService {
public partial class DatabaseService { public partial class DatabaseService {
public async Task<Resume?> GetResume(DbDataReader reader) { string GetString(DbDataReader reader, string name) {
return reader.IsDBNull(reader.GetOrdinal(name)) ? "" : reader.GetString(name);
}
public async Task<Resume?> GetResumeHeader(int ResumeID) {
using (MySqlConnection connection = GetConnection()) {
await connection.OpenAsync();
MySqlCommand cmd = new MySqlCommand("SELECT * FROM Resume WHERE ID = @ID;", connection);
cmd.Parameters.AddWithValue("@ID", ResumeID);
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) { while (await reader.ReadAsync()) {
if (reader == null) { break; }
int _id = reader.GetInt32("ID"); int _id = reader.GetInt32("ID");
int _accountid = reader.GetInt32("AccountID"); int _accountid = reader.GetInt32("AccountID");
string _title = reader.GetString("Title"); string _title = GetString(reader, "Title");
string _name = reader.GetString("Name"); string _name = GetString(reader, "Name");
string _field = reader.GetString("Field"); string _field = GetString(reader, "Field");
string _email = reader.GetString("Email"); string _email = GetString(reader, "Email");
string _phonenumber = reader.GetString("PhoneNumber"); string _phonenumber = GetString(reader, "PhoneNumber");
string _postalcode = reader.GetString("PostalCode"); string _postalcode = GetString(reader, "PostalCode");
string _country = reader.GetString("Country"); string _country = GetString(reader, "Country");
string _state = reader.GetString("StateOrRegion"); string _state = GetString(reader, "StateOrRegion");
string _city = reader.GetString("City"); string _city = GetString(reader, "City");
bool _isactive = reader.GetBoolean("IsActive"); bool _isactive = reader.GetBoolean("IsActive");
return new Resume() { return new Resume() {
ID = _id, ID = _id,
@@ -35,39 +44,27 @@ namespace BoredCareers.Services.DatabaseService {
IsActive = _isactive IsActive = _isactive
}; };
} }
}
}
return null; return null;
} }
public async Task<ResumeExperienceBullet[]> GetResumeExperienceBullets(DbDataReader reader) { public async Task<ResumeExperience[]> GetResumeExperience(int resumeId) {
List<ResumeExperienceBullet> experienceBullets = new List<ResumeExperienceBullet>();
while (await reader.ReadAsync()) {
if (reader == null) { break; }
int _id = reader.GetInt32("ID");
int _resumeid = reader.GetInt32("ResumeID");
int _experienceid = reader.GetInt32("ResumeExperienceID");
string _jobfunction = reader.GetString("JobFunction");
experienceBullets.Add(new ResumeExperienceBullet() {
ID = _id,
ResumeID = _resumeid,
ResumeExperienceID = _experienceid,
JobFunction = _jobfunction
});
}
return experienceBullets.ToArray();
}
public async Task<ResumeExperience[]> GetResumeExperience(DbDataReader reader) {
List<ResumeExperience> experience = new List<ResumeExperience>(); List<ResumeExperience> experience = new List<ResumeExperience>();
using (var conn = GetConnection()) {
await conn.OpenAsync();
var cmd = new MySqlCommand("SELECT * FROM ResumeExperience WHERE ResumeID = @ResumeID;", conn);
cmd.Parameters.AddWithValue("@ResumeID", resumeId);
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) { while (await reader.ReadAsync()) {
if (reader == null) { break; }
int _id = reader.GetInt32("ID"); int _id = reader.GetInt32("ID");
int _resumeid = reader.GetInt32("ResumeID"); int _resumeid = reader.GetInt32("ResumeID");
string _jobtitle = reader.GetString("JobTitle"); string _jobtitle = GetString(reader, "JobTitle");
string _company = reader.GetString("Company"); string _company = GetString(reader, "Company");
string _postalcode = reader.GetString("PostalCode"); string _postalcode = GetString(reader, "PostalCode");
string _country = reader.GetString("Country"); string _country = GetString(reader, "Country");
string _state = reader.GetString("StateOrRegion"); string _state = GetString(reader, "StateOrRegion");
string _city = reader.GetString("City"); string _city = GetString(reader, "City");
DateTime _datestarted = reader.GetDateTime("DateStarted"); DateTime _datestarted = reader.GetDateTime("DateStarted");
bool _stillempoyed = reader.GetBoolean("StillEmployed"); bool _stillempoyed = reader.GetBoolean("StillEmployed");
DateTime _dateended = reader.GetDateTime("DateEnded"); DateTime _dateended = reader.GetDateTime("DateEnded");
@@ -85,18 +82,48 @@ namespace BoredCareers.Services.DatabaseService {
DateEnded = _dateended, DateEnded = _dateended,
}); });
} }
}
}
return experience.ToArray(); return experience.ToArray();
} }
public async Task<ResumeMilitaryBullet[]> GetResumeMilitaryBullets(DbDataReader reader) { public async Task<ResumeExperienceBullet[]> GetResumeExperienceBullets(int resumeId) {
List<ResumeMilitaryBullet> militaryBullets = new List<ResumeMilitaryBullet>(); List<ResumeExperienceBullet> experienceBullets = new List<ResumeExperienceBullet>();
using (var conn = GetConnection()) {
await conn.OpenAsync();
var cmd = new MySqlCommand("SELECT * FROM ResumeExperienceBullet WHERE ResumeID = @ResumeID;", conn);
cmd.Parameters.AddWithValue("@ResumeID", resumeId);
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) {
int _id = reader.GetInt32("ID");
int _resumeid = reader.GetInt32("ResumeID");
int _experienceid = reader.GetInt32("ResumeExperienceID");
string _jobfunction = GetString(reader, "JobFunction");
experienceBullets.Add(new ResumeExperienceBullet() {
ID = _id,
ResumeID = _resumeid,
ResumeExperienceID = _experienceid,
JobFunction = _jobfunction
});
}
}
}
return experienceBullets.ToArray();
}
public async Task<ResumeMilitaryBullet[]> GetResumeMilitaryBullets(int resumeId) {
List<ResumeMilitaryBullet> militaryBullets = new List<ResumeMilitaryBullet>();
using (var conn = GetConnection()) {
await conn.OpenAsync();
var cmd = new MySqlCommand("SELECT * FROM ResumeMilitaryBullet WHERE ResumeID = @ResumeID;", conn);
cmd.Parameters.AddWithValue("@ResumeID", resumeId);
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) { while (await reader.ReadAsync()) {
if (reader == null) { break; }
int _id = reader.GetInt32("ID"); int _id = reader.GetInt32("ID");
int _resumeid = reader.GetInt32("ResumeID"); int _resumeid = reader.GetInt32("ResumeID");
int _experienceid = reader.GetInt32("ResumeMilitaryID"); int _experienceid = reader.GetInt32("ResumeMilitaryID");
string _achievement = reader.GetString("Achievement"); string _achievement = GetString(reader, "Achievement");
string _description = reader.GetString("Description"); string _description = GetString(reader, "Description");
militaryBullets.Add(new ResumeMilitaryBullet() { militaryBullets.Add(new ResumeMilitaryBullet() {
ID = _id, ID = _id,
ResumeID = _resumeid, ResumeID = _resumeid,
@@ -105,25 +132,29 @@ namespace BoredCareers.Services.DatabaseService {
Description = _description Description = _description
}); });
} }
}
}
return militaryBullets.ToArray(); return militaryBullets.ToArray();
} }
public async Task<ResumeMilitary?> GetResumeMilitary(DbDataReader reader) { public async Task<ResumeMilitary?> GetResumeMilitary(int resumeId) {
ResumeMilitary? military = null; ResumeMilitary? military = null;
using (var conn = GetConnection()) {
await conn.OpenAsync();
var cmd = new MySqlCommand("SELECT * FROM ResumeMilitary WHERE ResumeID = @ResumeID;", conn);
cmd.Parameters.AddWithValue("@ResumeID", resumeId);
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) { while (await reader.ReadAsync()) {
if (reader == null) { break; }
int _id = reader.GetInt32("ID"); int _id = reader.GetInt32("ID");
int _resumeid = reader.GetInt32("ResumeID"); int _resumeid = reader.GetInt32("ResumeID");
bool _veteran = reader.GetBoolean("Veteran"); string _country = GetString(reader, "Country");
string _country = reader.GetString("Country"); string _rank = GetString(reader, "Rank");
string _rank = reader.GetString("Rank");
DateTime _datestarted = reader.GetDateTime("DateStarted"); DateTime _datestarted = reader.GetDateTime("DateStarted");
bool _stillServing = reader.GetBoolean("StillServing"); bool _stillServing = reader.GetBoolean("StillServing");
DateTime _dateended = reader.GetDateTime("DateEnded"); DateTime _dateended = reader.GetDateTime("DateEnded");
military = new ResumeMilitary() { military = new ResumeMilitary() {
ID = _id, ID = _id,
ResumeID = _resumeid, ResumeID = _resumeid,
Veteran = _veteran,
Country = _country, Country = _country,
Rank = _rank, Rank = _rank,
DateStarted = _datestarted, DateStarted = _datestarted,
@@ -131,22 +162,28 @@ namespace BoredCareers.Services.DatabaseService {
DateEnded = _dateended, DateEnded = _dateended,
}; };
} }
}
}
return military; return military;
} }
public async Task<ResumeEducation[]> GetResumeEducation(DbDataReader reader) { public async Task<ResumeEducation[]> GetResumeEducation(int resumeId) {
List<ResumeEducation>? education = new List<ResumeEducation>(); List<ResumeEducation>? education = new List<ResumeEducation>();
using (var conn = GetConnection()) {
await conn.OpenAsync();
var cmd = new MySqlCommand("SELECT * FROM ResumeEducation WHERE ResumeID = @ResumeID;", conn);
cmd.Parameters.AddWithValue("@ResumeID", resumeId);
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) { while (await reader.ReadAsync()) {
if (reader == null) { break; }
int _id = reader.GetInt32("ID"); int _id = reader.GetInt32("ID");
int _resumeid = reader.GetInt32("ResumeID"); int _resumeid = reader.GetInt32("ResumeID");
string _degreetype = reader.GetString("DegreeType"); string _degreetype = GetString(reader, "DegreeType");
string _degreefield = reader.GetString("DegreeField"); string _degreefield = GetString(reader, "DegreeField");
string _school = reader.GetString("School"); string _school = GetString(reader, "School");
string _postalcode = reader.GetString("PostalCode"); string _postalcode = GetString(reader, "PostalCode");
string _country = reader.GetString("Country"); string _country = GetString(reader, "Country");
string _state = reader.GetString("StateOrRegion"); string _state = GetString(reader, "StateOrRegion");
string _city = reader.GetString("City"); string _city = GetString(reader, "City");
DateTime _datestarted = reader.GetDateTime("DateStarted"); DateTime _datestarted = reader.GetDateTime("DateStarted");
bool _stillstudying = reader.GetBoolean("StillStudying"); bool _stillstudying = reader.GetBoolean("StillStudying");
DateTime _dateended = reader.GetDateTime("DateEnded"); DateTime _dateended = reader.GetDateTime("DateEnded");
@@ -165,17 +202,23 @@ namespace BoredCareers.Services.DatabaseService {
DateEnded = _dateended DateEnded = _dateended
}); });
} }
}
}
return education.ToArray(); return education.ToArray();
} }
public async Task<ResumeSkill[]> GetResumeSkills(DbDataReader reader) { public async Task<ResumeSkill[]> GetResumeSkills(int resumeId) {
List<ResumeSkill> skills = new List<ResumeSkill>(); List<ResumeSkill> skills = new List<ResumeSkill>();
using (var conn = GetConnection()) {
await conn.OpenAsync();
var cmd = new MySqlCommand("SELECT * FROM ResumeSkill WHERE ResumeID = @ResumeID;", conn);
cmd.Parameters.AddWithValue("@ResumeID", resumeId);
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) { while (await reader.ReadAsync()) {
if (reader == null) { break; }
int _id = reader.GetInt32("ID"); int _id = reader.GetInt32("ID");
int _resumeid = reader.GetInt32("ResumeID"); int _resumeid = reader.GetInt32("ResumeID");
string _name = reader.GetString("Name"); string _name = GetString(reader, "Name");
string _description = reader.GetString("Description"); string _description = GetString(reader, "Description");
skills.Add(new ResumeSkill { skills.Add(new ResumeSkill {
ID = _id, ID = _id,
ResumeID = _resumeid, ResumeID = _resumeid,
@@ -183,17 +226,23 @@ namespace BoredCareers.Services.DatabaseService {
Description = _description Description = _description
}); });
} }
}
}
return skills.ToArray(); return skills.ToArray();
} }
public async Task<ResumeLanguage[]> GetResumeLanguages(DbDataReader reader) { public async Task<ResumeLanguage[]> GetResumeLanguages(int resumeId) {
List<ResumeLanguage>? languages = new List<ResumeLanguage>(); List<ResumeLanguage>? languages = new List<ResumeLanguage>();
using (var conn = GetConnection()) {
await conn.OpenAsync();
var cmd = new MySqlCommand("SELECT * FROM ResumeLanguage WHERE ResumeID = @ResumeID;", conn);
cmd.Parameters.AddWithValue("@ResumeID", resumeId);
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) { while (await reader.ReadAsync()) {
if (reader == null) { break; }
int _id = reader.GetInt32("ID"); int _id = reader.GetInt32("ID");
int _resumeid = reader.GetInt32("ResumeID"); int _resumeid = reader.GetInt32("ResumeID");
string _language = reader.GetString("Language"); string _language = GetString(reader, "Language");
string _proficiency = reader.GetString("Proficiency"); string _proficiency = GetString(reader, "Proficiency");
languages.Add(new ResumeLanguage { languages.Add(new ResumeLanguage {
ID = _id, ID = _id,
ResumeID = _resumeid, ResumeID = _resumeid,
@@ -201,18 +250,24 @@ namespace BoredCareers.Services.DatabaseService {
Proficiency = _proficiency Proficiency = _proficiency
}); });
} }
}
}
return languages.ToArray(); return languages.ToArray();
} }
public async Task<ResumeCertification[]> GetResumeCertification(DbDataReader reader) { public async Task<ResumeCertification[]> GetResumeCertification(int resumeId) {
List<ResumeCertification> certs = new List<ResumeCertification>(); List<ResumeCertification> certs = new List<ResumeCertification>();
using (var conn = GetConnection()) {
await conn.OpenAsync();
var cmd = new MySqlCommand("SELECT * FROM ResumeCertification WHERE ResumeID = @ResumeID;", conn);
cmd.Parameters.AddWithValue("@ResumeID", resumeId);
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) { while (await reader.ReadAsync()) {
if (reader == null) { break; }
int _id = reader.GetInt32("ID"); int _id = reader.GetInt32("ID");
int _resumeid = reader.GetInt32("ResumeID"); int _resumeid = reader.GetInt32("ResumeID");
string _name = reader.GetString("Name"); string _name = GetString(reader, "Name");
string _url = reader.GetString("VerificationURL"); string _url = GetString(reader, "VerificationURL");
string _description = reader.GetString("Description"); string _description = GetString(reader, "Description");
certs.Add(new ResumeCertification { certs.Add(new ResumeCertification {
ID = _id, ID = _id,
ResumeID = _resumeid, ResumeID = _resumeid,
@@ -221,18 +276,24 @@ namespace BoredCareers.Services.DatabaseService {
Description = _description Description = _description
}); });
} }
}
}
return certs.ToArray(); return certs.ToArray();
} }
public async Task<ResumeProject[]> GetResumeProjects(DbDataReader reader) { public async Task<ResumeProject[]> GetResumeProjects(int resumeId) {
List<ResumeProject>? projects = new List<ResumeProject>(); List<ResumeProject>? projects = new List<ResumeProject>();
using (var conn = GetConnection()) {
await conn.OpenAsync();
var cmd = new MySqlCommand("SELECT * FROM ResumeProject WHERE ResumeID = @ResumeID;", conn);
cmd.Parameters.AddWithValue("@ResumeID", resumeId);
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
while (await reader.ReadAsync()) { while (await reader.ReadAsync()) {
if (reader == null) { break; }
int _id = reader.GetInt32("ID"); int _id = reader.GetInt32("ID");
int _resumeid = reader.GetInt32("ResumeID"); int _resumeid = reader.GetInt32("ResumeID");
string _name = reader.GetString("Name"); string _name = GetString(reader, "Name");
string _url = reader.GetString("URL"); string _url = GetString(reader, "URL");
string _description = reader.GetString("Description"); string _description = GetString(reader, "Description");
projects.Add(new ResumeProject { projects.Add(new ResumeProject {
ID = _id, ID = _id,
ResumeID = _resumeid, ResumeID = _resumeid,
@@ -241,8 +302,9 @@ namespace BoredCareers.Services.DatabaseService {
Description = _description Description = _description
}); });
} }
}
}
return projects.ToArray(); return projects.ToArray();
} }
} }
} }
@@ -4,7 +4,9 @@ using MySql.Data.MySqlClient;
namespace BoredCareers.Services.DatabaseService { namespace BoredCareers.Services.DatabaseService {
public partial class DatabaseService { public partial class DatabaseService {
public async Task SetResume(MySqlConnection connection, Resume resume) { public async Task<int> SetResumeHeader(Resume resume) {
using (var conn = GetConnection()) {
await conn.OpenAsync();
string command = @" string command = @"
INSERT INTO Resume INSERT INTO Resume
(ID,AccountID,Title,Name,Field,Email,PhoneNumber,PostalCode,Country,StateOrRegion,City,IsActive) (ID,AccountID,Title,Name,Field,Email,PhoneNumber,PostalCode,Country,StateOrRegion,City,IsActive)
@@ -22,9 +24,11 @@ namespace BoredCareers.Services.DatabaseService {
StateOrRegion = @StateOrRegion, StateOrRegion = @StateOrRegion,
City = @City, City = @City,
IsActive = @IsActive; IsActive = @IsActive;
SELECT LAST_INSERT_ID();
"; ";
MySqlCommand cmd = new MySqlCommand(command, connection); MySqlCommand cmd = new MySqlCommand(command, conn);
cmd.Parameters.AddWithValue("@ID", resume.ID); cmd.Parameters.AddWithValue("@ID", resume.ID);
cmd.Parameters.AddWithValue("@AccountID", resume.AccountID); cmd.Parameters.AddWithValue("@AccountID", resume.AccountID);
cmd.Parameters.AddWithValue("@Title", resume.Title); cmd.Parameters.AddWithValue("@Title", resume.Title);
@@ -37,14 +41,22 @@ namespace BoredCareers.Services.DatabaseService {
cmd.Parameters.AddWithValue("@StateOrRegion", resume.StateOrRegion); cmd.Parameters.AddWithValue("@StateOrRegion", resume.StateOrRegion);
cmd.Parameters.AddWithValue("@City", resume.City); cmd.Parameters.AddWithValue("@City", resume.City);
cmd.Parameters.AddWithValue("@IsActive", resume.IsActive); cmd.Parameters.AddWithValue("@IsActive", resume.IsActive);
object? result = await cmd.ExecuteScalarAsync();
await cmd.ExecuteNonQueryAsync(); if (resume.ID != null && resume.ID != 0) {
return Convert.ToInt32(resume.ID);
} else {
cmd.CommandText = "";
return Convert.ToInt32(result);
}
}
} }
public async Task SetResumeExperienceBullets(MySqlConnection connection, ResumeExperienceBullet[] bullets) { public async Task SetResumeExperienceBullets(ResumeExperienceBullet bullet) {
foreach (ResumeExperienceBullet cur in bullets) { using (var conn = GetConnection()) {
await conn.OpenAsync();
string command = @" string command = @"
INSERT INTO Resume INSERT INTO ResumeExperienceBullet
(ID,ResumeID,ResumeExperienceID,JobFunction) (ID,ResumeID,ResumeExperienceID,JobFunction)
VALUES VALUES
(@ID,@ResumeID,@ResumeExperienceID,@JobFunction) (@ID,@ResumeID,@ResumeExperienceID,@JobFunction)
@@ -54,20 +66,21 @@ namespace BoredCareers.Services.DatabaseService {
JobFunction = @JobFunction; JobFunction = @JobFunction;
"; ";
MySqlCommand cmd = new MySqlCommand(command, connection); MySqlCommand cmd = new MySqlCommand(command, conn);
cmd.Parameters.AddWithValue("@ID", cur.ID); cmd.Parameters.AddWithValue("@ID", bullet.ID);
cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID); cmd.Parameters.AddWithValue("@ResumeID", bullet.ResumeID);
cmd.Parameters.AddWithValue("@ResumeExperienceID", cur.ResumeExperienceID); cmd.Parameters.AddWithValue("@ResumeExperienceID", bullet.ResumeExperienceID);
cmd.Parameters.AddWithValue("@JobFunction", cur.JobFunction); cmd.Parameters.AddWithValue("@JobFunction", bullet.JobFunction);
await cmd.ExecuteNonQueryAsync(); await cmd.ExecuteNonQueryAsync();
} }
} }
public async Task SetResumeExperience(MySqlConnection connection, ResumeExperience[] experiences) { public async Task<ResumeExperience> SetResumeExperience(ResumeExperience experiences) {
foreach (ResumeExperience cur in experiences) { using (var conn = GetConnection()) {
await conn.OpenAsync();
string command = @" string command = @"
INSERT INTO Resume INSERT INTO ResumeExperience
(ID,ResumeID,JobTitle,Company,PostalCode,Country,StateOrRegion,City,DateStarted,StillEmployed,DateEnded) (ID,ResumeID,JobTitle,Company,PostalCode,Country,StateOrRegion,City,DateStarted,StillEmployed,DateEnded)
VALUES VALUES
(@ID,@ResumeID,@JobTitle,@Company,@PostalCode,@Country,@StateOrRegion,@City,@DateStarted,@StillEmployed,@DateEnded) (@ID,@ResumeID,@JobTitle,@Company,@PostalCode,@Country,@StateOrRegion,@City,@DateStarted,@StillEmployed,@DateEnded)
@@ -82,26 +95,37 @@ namespace BoredCareers.Services.DatabaseService {
DateStarted = @DateStarted, DateStarted = @DateStarted,
StillEmployed = @StillEmployed, StillEmployed = @StillEmployed,
DateEnded = @DateEnded; DateEnded = @DateEnded;
SELECT LAST_INSERT_ID();
"; ";
MySqlCommand cmd = new MySqlCommand(command, connection); MySqlCommand cmd = new MySqlCommand(command, conn);
cmd.Parameters.AddWithValue("@ID", cur.ID); cmd.Parameters.AddWithValue("@ID", experiences.ID);
cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID); cmd.Parameters.AddWithValue("@ResumeID", experiences.ResumeID);
cmd.Parameters.AddWithValue("@JobTitle", cur.JobTitle); cmd.Parameters.AddWithValue("@JobTitle", experiences.JobTitle);
cmd.Parameters.AddWithValue("@Company", cur.Company); cmd.Parameters.AddWithValue("@Company", experiences.Company);
cmd.Parameters.AddWithValue("@PostalCode", cur.PostalCode); cmd.Parameters.AddWithValue("@Country", experiences.Country);
cmd.Parameters.AddWithValue("@DateStarted", cur.DateStarted.ToUniversalTime()); cmd.Parameters.AddWithValue("@StateOrRegion", experiences.StateOrRegion);
cmd.Parameters.AddWithValue("@StillEmployed", cur.StillEmployed); cmd.Parameters.AddWithValue("@City", experiences.City);
cmd.Parameters.AddWithValue("@DateEnded", cur.DateEnded.ToUniversalTime()); cmd.Parameters.AddWithValue("@PostalCode", experiences.PostalCode);
cmd.Parameters.AddWithValue("@DateStarted", experiences.DateStarted.ToUniversalTime());
cmd.Parameters.AddWithValue("@StillEmployed", experiences.StillEmployed);
cmd.Parameters.AddWithValue("@DateEnded", experiences.DateEnded.ToUniversalTime());
object? result = await cmd.ExecuteScalarAsync();
await cmd.ExecuteNonQueryAsync(); if (experiences.ID == null) {
experiences.ID = Convert.ToInt32(result);
}
return experiences;
} }
} }
public async Task SetResumeMilitaryBullets(MySqlConnection connection, ResumeMilitaryBullet[] bullets) { public async Task SetResumeMilitaryBullets(ResumeMilitaryBullet[] bullets) {
using (var conn = GetConnection()) {
await conn.OpenAsync();
foreach (ResumeMilitaryBullet cur in bullets) { foreach (ResumeMilitaryBullet cur in bullets) {
string command = @" string command = @"
INSERT INTO Resume INSERT INTO ResumeMilitaryBullet
(ID,ResumeID,ResumeMilitaryID,Achievement) (ID,ResumeID,ResumeMilitaryID,Achievement)
VALUES VALUES
(@ID,@ResumeID,@ResumeMilitaryID,@Achievement) (@ID,@ResumeID,@ResumeMilitaryID,@Achievement)
@@ -112,7 +136,7 @@ namespace BoredCareers.Services.DatabaseService {
Description = @Description; Description = @Description;
"; ";
MySqlCommand cmd = new MySqlCommand(command, connection); MySqlCommand cmd = new MySqlCommand(command, conn);
cmd.Parameters.AddWithValue("@ID", cur.ID); cmd.Parameters.AddWithValue("@ID", cur.ID);
cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID); cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
cmd.Parameters.AddWithValue("@ResumeMilitaryID", cur.ResumeMilitaryID); cmd.Parameters.AddWithValue("@ResumeMilitaryID", cur.ResumeMilitaryID);
@@ -122,40 +146,53 @@ namespace BoredCareers.Services.DatabaseService {
await cmd.ExecuteNonQueryAsync(); await cmd.ExecuteNonQueryAsync();
} }
} }
}
public async Task SetResumeMilitary(MySqlConnection connection, ResumeMilitary military) { public async Task<ResumeMilitary> SetResumeMilitary(ResumeMilitary? military) {
using (var conn = GetConnection()) {
await conn.OpenAsync();
if (military != null) {
string command = @" string command = @"
INSERT INTO Resume INSERT INTO ResumeMilitary
(ID,ResumeID,Veteran,Country,Rank,DateStarted,StillServing,DateEnded) (ID,ResumeID,Country,`Rank`,DateStarted,StillServing,DateEnded)
VALUES VALUES
(@ID,@ResumeID,@Veteran,@Country,@Rank,@DateStarted,@StillServing,@DateEnded) (@ID,@ResumeID,@Country,@Rank,@DateStarted,@StillServing,@DateEnded)
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
ResumeID = @ResumeID, ResumeID = @ResumeID,
Veteran = @Veteran,
Country = @Country, Country = @Country,
Rank = @Rank, `Rank` = @Rank,
DateStarted = @DateStarted, DateStarted = @DateStarted,
StillServing = @StillServing, StillServing = @StillServing,
DateEnded = @DateEnded; DateEnded = @DateEnded;
SELECT LAST_INSERT_ID();
"; ";
MySqlCommand cmd = new MySqlCommand(command, connection); MySqlCommand cmd = new MySqlCommand(command, conn);
cmd.Parameters.AddWithValue("@ID", military.ID); cmd.Parameters.AddWithValue("@ID", military.ID);
cmd.Parameters.AddWithValue("@ResumeID", military.ResumeID); cmd.Parameters.AddWithValue("@ResumeID", military.ResumeID);
cmd.Parameters.AddWithValue("@Veteran", military.Veteran);
cmd.Parameters.AddWithValue("@Country", military.Country); cmd.Parameters.AddWithValue("@Country", military.Country);
cmd.Parameters.AddWithValue("@Rank", military.Rank); cmd.Parameters.AddWithValue("@Rank", military.Rank);
cmd.Parameters.AddWithValue("@DateStarted", military.DateStarted.ToUniversalTime()); cmd.Parameters.AddWithValue("@DateStarted", military.DateStarted.ToUniversalTime());
cmd.Parameters.AddWithValue("@StillServing", military.StillServing); cmd.Parameters.AddWithValue("@StillServing", military.StillServing);
cmd.Parameters.AddWithValue("@DateEnded", military.DateEnded.ToUniversalTime()); cmd.Parameters.AddWithValue("@DateEnded", military.DateEnded.ToUniversalTime());
object? result = await cmd.ExecuteScalarAsync();
await cmd.ExecuteNonQueryAsync(); if (military.ID == null) {
military.ID = Convert.ToInt32(result);
}
return military;
}
return new ResumeMilitary();
}
} }
public async Task SetResumeEducation(MySqlConnection connection, ResumeEducation[] educations) { public async Task SetResumeEducation(ResumeEducation[] educations) {
using (var conn = GetConnection()) {
await conn.OpenAsync();
foreach (ResumeEducation cur in educations) { foreach (ResumeEducation cur in educations) {
string command = @" string command = @"
INSERT INTO Resume INSERT INTO ResumeEducation
(ID,ResumeID,DegreeType,DegreeField,School,PostalCode,Country,StateOrRegion,City,DateStarted,StillStudying,DateEnded) (ID,ResumeID,DegreeType,DegreeField,School,PostalCode,Country,StateOrRegion,City,DateStarted,StillStudying,DateEnded)
VALUES VALUES
(@ID,@ResumeID,@DegreeType,@DegreeField,@School,@PostalCode,@Country,@StateOrRegion,@City,@DateStarted,@StillStudying,@DateEnded) (@ID,@ResumeID,@DegreeType,@DegreeField,@School,@PostalCode,@Country,@StateOrRegion,@City,@DateStarted,@StillStudying,@DateEnded)
@@ -173,7 +210,7 @@ namespace BoredCareers.Services.DatabaseService {
DateEnded = @DateEnded; DateEnded = @DateEnded;
"; ";
MySqlCommand cmd = new MySqlCommand(command, connection); MySqlCommand cmd = new MySqlCommand(command, conn);
cmd.Parameters.AddWithValue("@ID", cur.ID); cmd.Parameters.AddWithValue("@ID", cur.ID);
cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID); cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
cmd.Parameters.AddWithValue("@DegreeType", cur.DegreeType); cmd.Parameters.AddWithValue("@DegreeType", cur.DegreeType);
@@ -190,11 +227,14 @@ namespace BoredCareers.Services.DatabaseService {
await cmd.ExecuteNonQueryAsync(); await cmd.ExecuteNonQueryAsync();
} }
} }
}
public async Task SetResumeSkills(MySqlConnection connection, ResumeSkill[] skills) { public async Task SetResumeSkills(ResumeSkill[] skills) {
using (var conn = GetConnection()) {
await conn.OpenAsync();
foreach (ResumeSkill cur in skills) { foreach (ResumeSkill cur in skills) {
string command = @" string command = @"
INSERT INTO Resume INSERT INTO ResumeSkill
(ID,ResumeID,Name,Description) (ID,ResumeID,Name,Description)
VALUES VALUES
(@ID,@ResumeID,@Name,@Description) (@ID,@ResumeID,@Name,@Description)
@@ -204,7 +244,7 @@ namespace BoredCareers.Services.DatabaseService {
Description = @Description; Description = @Description;
"; ";
MySqlCommand cmd = new MySqlCommand(command, connection); MySqlCommand cmd = new MySqlCommand(command, conn);
cmd.Parameters.AddWithValue("@ID", cur.ID); cmd.Parameters.AddWithValue("@ID", cur.ID);
cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID); cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
cmd.Parameters.AddWithValue("@Name", cur.Name); cmd.Parameters.AddWithValue("@Name", cur.Name);
@@ -213,11 +253,14 @@ namespace BoredCareers.Services.DatabaseService {
await cmd.ExecuteNonQueryAsync(); await cmd.ExecuteNonQueryAsync();
} }
} }
}
public async Task SetResumeLanguages(MySqlConnection connection, ResumeLanguage[] languages) { public async Task SetResumeLanguages(ResumeLanguage[] languages) {
using (var conn = GetConnection()) {
await conn.OpenAsync();
foreach (ResumeLanguage cur in languages) { foreach (ResumeLanguage cur in languages) {
string command = @" string command = @"
INSERT INTO Resume INSERT INTO ResumeLanguage
(ID,ResumeID,Language,Proficiency) (ID,ResumeID,Language,Proficiency)
VALUES VALUES
(@ID,@ResumeID,@Language,@Proficiency) (@ID,@ResumeID,@Language,@Proficiency)
@@ -227,7 +270,7 @@ namespace BoredCareers.Services.DatabaseService {
Proficiency = @Proficiency; Proficiency = @Proficiency;
"; ";
MySqlCommand cmd = new MySqlCommand(command, connection); MySqlCommand cmd = new MySqlCommand(command, conn);
cmd.Parameters.AddWithValue("@ID", cur.ID); cmd.Parameters.AddWithValue("@ID", cur.ID);
cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID); cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
cmd.Parameters.AddWithValue("@Language", cur.Language); cmd.Parameters.AddWithValue("@Language", cur.Language);
@@ -236,22 +279,25 @@ namespace BoredCareers.Services.DatabaseService {
await cmd.ExecuteNonQueryAsync(); await cmd.ExecuteNonQueryAsync();
} }
} }
}
public async Task SetResumeCertification(MySqlConnection connection, ResumeCertification[] certifications) { public async Task SetResumeCertification(ResumeCertification[] certifications) {
using (var conn = GetConnection()) {
await conn.OpenAsync();
foreach (ResumeCertification cur in certifications) { foreach (ResumeCertification cur in certifications) {
string command = @" string command = @"
INSERT INTO Resume INSERT INTO ResumeCertification
(ID,ResumeID,Name,VerificationURL,Description) (ID,ResumeID,Name,VerificationURL,Description)
VALUES VALUES
(@ID,@ResumeID,@Name,@VerificationURL,@Description) (@ID,@ResumeID,@Name,@VerificationURL,@Description)
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
ResumeID = @ResumeID, ResumeID = @ResumeID,
Name = @DegreeNameType, Name = @Name,
VerificationURL = @VerificationURL, VerificationURL = @VerificationURL,
Description = @Description; Description = @Description;
"; ";
MySqlCommand cmd = new MySqlCommand(command, connection); MySqlCommand cmd = new MySqlCommand(command, conn);
cmd.Parameters.AddWithValue("@ID", cur.ID); cmd.Parameters.AddWithValue("@ID", cur.ID);
cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID); cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
cmd.Parameters.AddWithValue("@Name", cur.Name); cmd.Parameters.AddWithValue("@Name", cur.Name);
@@ -261,11 +307,14 @@ namespace BoredCareers.Services.DatabaseService {
await cmd.ExecuteNonQueryAsync(); await cmd.ExecuteNonQueryAsync();
} }
} }
}
public async Task SetResumeProjects(MySqlConnection connection, ResumeProject[] projects) { public async Task SetResumeProjects(ResumeProject[] projects) {
using (var conn = GetConnection()) {
await conn.OpenAsync();
foreach (ResumeProject cur in projects) { foreach (ResumeProject cur in projects) {
string command = @" string command = @"
INSERT INTO Resume INSERT INTO ResumeProject
(ID,ResumeID,Name,URL,Description) (ID,ResumeID,Name,URL,Description)
VALUES VALUES
(@ID,@ResumeID,@Name,@URL,@Description) (@ID,@ResumeID,@Name,@URL,@Description)
@@ -276,7 +325,7 @@ namespace BoredCareers.Services.DatabaseService {
Description = @Description; Description = @Description;
"; ";
MySqlCommand cmd = new MySqlCommand(command, connection); MySqlCommand cmd = new MySqlCommand(command, conn);
cmd.Parameters.AddWithValue("@ID", cur.ID); cmd.Parameters.AddWithValue("@ID", cur.ID);
cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID); cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
cmd.Parameters.AddWithValue("@Name", cur.Name); cmd.Parameters.AddWithValue("@Name", cur.Name);
@@ -286,6 +335,7 @@ namespace BoredCareers.Services.DatabaseService {
await cmd.ExecuteNonQueryAsync(); await cmd.ExecuteNonQueryAsync();
} }
} }
}
} }
} }