- @for(military of resume.military.millitaryBullets; track military.trackUUID ){
+ @for(military of resume.military.militaryBullets; track military.trackUUID ){
ADD Education
- @for(education of resume.education; track education.trackUUID){
+ @for(education of resume.educations; track education.trackUUID){
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@if (!education.stillStudying){
-
+
}
DEL Education
@@ -90,8 +91,8 @@
ADD Skill
@for(skill of resume.skills; track skill.trackUUID){
-
-
+
+
DEL Skill
}
@@ -102,8 +103,8 @@
ADD Language
@for(language of resume.languages; track language.trackUUID){
-
-
+
+
DEL Language
}
@@ -113,11 +114,11 @@
ADD Certification
- @for(cert of resume.certification; track cert.trackUUID){
+ @for(cert of resume.certifications; track cert.trackUUID){
-
-
-
+
+
+
DEL Certification
}
@@ -128,9 +129,9 @@
ADD Project
@for(proj of resume.projects; track proj.trackUUID){
-
-
-
+
+
+
DEL Project
}
diff --git a/src/Client/src/app/pages/resumes/editor/editor.component.ts b/src/Client/src/app/pages/resumes/editor/editor.component.ts
index bbbbd10..925131e 100644
--- a/src/Client/src/app/pages/resumes/editor/editor.component.ts
+++ b/src/Client/src/app/pages/resumes/editor/editor.component.ts
@@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms';
import { Router, ActivatedRoute, RouterModule } from '@angular/router';
import { Title } from '@angular/platform-browser';
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 { HomeComponent } from "app/pages/home/home.component";
@@ -33,6 +33,7 @@ export class ResumesEditorComponent {
this.http.get
("api/resume?ResumeID=" + ResumeID).subscribe({
next: data => {
this.resume = data;
+ this.milCache = data.military;
this.isNewResume = false;
},
error: err => {
@@ -56,13 +57,13 @@ export class ResumesEditorComponent {
}
addExperience(){
- this.resume.experience.push( new ResumeExperience );
+ this.resume.experiences.push( new ResumeExperience );
}
delExperience(self: ResumeExperience){
- for(let i=0; i
@for(resume of myResumes; track myResumes.length){
- {{ resume.title }}
+ @if (resume.id != null){
+ {{ resume.title }}
+ }
}
NEW RESUME
diff --git a/src/Server/Entities/Resume.cs b/src/Server/Entities/Resume.cs
index 8457400..31fc5db 100644
--- a/src/Server/Entities/Resume.cs
+++ b/src/Server/Entities/Resume.cs
@@ -12,18 +12,18 @@ namespace BoredCareers.Entities {
public string StateOrRegion { get; set; } = "";
public string City { get; set; } = "";
public bool IsActive { get; set; } = false;
- public ResumeExperience[] Experience { get; set; } = [];
- public ResumeMilitary Millitary { get; set; } = new ResumeMilitary();
+ public ResumeExperience[] Experiences { get; set; } = [];
+ public ResumeMilitary? Military { get; set; } = null;
public ResumeEducation[] Educations { get; set; } = [];
public ResumeSkill[] Skills { get; set; } = [];
public ResumeLanguage[] Languages { get; set; } = [];
- public ResumeCertification[] Certification { get; set; } = [];
+ public ResumeCertification[] Certifications { get; set; } = [];
public ResumeProject[] Projects { get; set; } = [];
}
public class ResumeExperience {
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 Company { get; set; } = "";
public string PostalCode { get; set; } = "";
@@ -38,34 +38,33 @@ namespace BoredCareers.Entities {
public class ResumeExperienceBullet {
public int? ID { get; set; } // PK
- public int ResumeID { get; set; } // FK
- public int ResumeExperienceID { get; set; } // FK
+ 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 ResumeID { get; set; } // FK
- public bool Veteran { get; set; } = false;
+ public int? ResumeID { get; set; } // FK
public string Country { get; set; } = ""; // 2 Letter Country Code
public string Rank { get; set; } = "";
public DateTime DateStarted { get; set; } = new DateTime();
public bool StillServing { get; set; } = false;
public DateTime DateEnded { get; set; } = new DateTime();
- public ResumeMilitaryBullet[] MillitaryBullets = [];
+ public ResumeMilitaryBullet[] MilitaryBullets { get; set; } = [];
}
public class ResumeMilitaryBullet {
public int? ID { get; set; } // PK
- public int ResumeID { get; set; } // FK
- public int ResumeMilitaryID { get; set; } // FK
+ public int? ResumeID { get; set; } // FK
+ public int? ResumeMilitaryID { get; set; } // FK
public string Achievement { get; set; } = "";
public string Description { get; set; } = "";
}
public class ResumeEducation {
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 DegreeField { get; set; } = "";
public string School { get; set; } = "";
@@ -80,21 +79,21 @@ namespace BoredCareers.Entities {
public class ResumeSkill {
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 Description { get; set; } = "";
}
public class ResumeLanguage {
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 Proficiency { get; set; } = "";
}
public class ResumeCertification {
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 VerificationURL { get; set; } = "";
public string Description { get; set; } = "";
@@ -102,7 +101,7 @@ namespace BoredCareers.Entities {
public class ResumeProject {
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 URL { get; set; } = "";
public string Description { get; set; } = "";
diff --git a/src/Server/Services/DatabaseService/Resume.cs b/src/Server/Services/DatabaseService/Resume.cs
index 35cf14e..10cee22 100644
--- a/src/Server/Services/DatabaseService/Resume.cs
+++ b/src/Server/Services/DatabaseService/Resume.cs
@@ -59,164 +59,126 @@ namespace BoredCareers.Services.DatabaseService {
}
public async Task
GetResume(int ResumeID) {
- // Open connections for multi-threaded request
- MySqlConnection resumeConnection = GetConnection();
- 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();
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
- // Open the connections
- Task resumeopen = resumeConnection.OpenAsync();
- Task resumeexperienceopen = ResumeExperienceConnection.OpenAsync();
- 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();
+ // Check if resume header exists
+ Resume? resume = await GetResumeHeader(ResumeID);
+ if (resume == null) { return null; }
- // Wait for all the connections to open
- await Task.WhenAll(resumeopen, resumeexperienceopen, resumeexperiencebulletopen, resumemilitaryopen, resumemilitarybulletopen,
- resumeeducationopen, resumeskillopen, resumelanguageopen, resumecertifcationopen, resumeprojectopen);
+ // Create parallel threads
+ Task experienceTask = GetResumeExperience(ResumeID);
+ Task experienceBulletsTask = GetResumeExperienceBullets(ResumeID);
+ Task militaryTask = GetResumeMilitary(ResumeID);
+ Task militaryBulletsTask = GetResumeMilitaryBullets(ResumeID);
+ Task educationTask = GetResumeEducation(ResumeID);
+ Task skillsTask = GetResumeSkills(ResumeID);
+ Task languagesTask = GetResumeLanguages(ResumeID);
+ Task certificationTask = GetResumeCertification(ResumeID);
+ Task projectsTask = GetResumeProjects(ResumeID);
- // Setup the commands for the connections
- MySqlCommand resumeCommand = new MySqlCommand("SELECT * FROM Resume WHERE ID = @ResumeID;", resumeConnection);
- MySqlCommand ResumeExperienceCommand = new MySqlCommand("SELECT * FROM ResumeExperience WHERE ResumeID = @ResumeID;", ResumeExperienceConnection);
- MySqlCommand ResumeExperienceBulletCommand = new MySqlCommand("SELECT * FROM ResumeExperienceBullet WHERE ResumeID = @ResumeID;", ResumeExperienceBulletConnection);
- MySqlCommand ResumeMilitaryCommand = new MySqlCommand("SELECT * FROM ResumeMilitary WHERE ResumeID = @ResumeID;", ResumeMilitaryConnection);
- MySqlCommand ResumeMilitaryBulletCommand = new MySqlCommand("SELECT * FROM ResumeMilitaryBullet WHERE ResumeID = @ResumeID", ResumeMilitaryBulletConnection);
- MySqlCommand ResumeEducationCommand = new MySqlCommand("SELECT * FROM ResumeEducation WHERE ResumeID = @ResumeID;", ResumeEducationConnection);
- MySqlCommand ResumeSkillCommand = new MySqlCommand("SELECT * FROM ResumeSkill WHERE ResumeID = @ResumeID;", ResumeSkillConnection);
- MySqlCommand ResumeLanguageCommand = new MySqlCommand("SELECT * FROM ResumeLanguage WHERE ResumeID = @ResumeID;", ResumeLanguageConnection);
- MySqlCommand ResumeCertificationCommand = new MySqlCommand("SELECT * FROM ResumeCertification WHERE ResumeID = @ResumeID;", ResumeCertificationConnection);
- MySqlCommand ResumeProjectCommand = new MySqlCommand("SELECT * FROM ResumeProject WHERE ResumeID = @ResumeID;", ResumeProjectConnection);
+ // Run all in parallel
+ await Task.WhenAll(
+ experienceTask,
+ experienceBulletsTask,
+ militaryTask,
+ militaryBulletsTask,
+ educationTask,
+ skillsTask,
+ languagesTask,
+ certificationTask,
+ projectsTask
+ );
- // Add parameters to the commands
- resumeCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
- ResumeExperienceCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
- ResumeExperienceBulletCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
- ResumeMilitaryCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
- ResumeMilitaryBulletCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
- ResumeEducationCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
- ResumeSkillCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
- ResumeLanguageCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
- ResumeCertificationCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
- ResumeProjectCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
+ // Get results from parallel processes
+ ResumeExperience[] experience = await experienceTask;
+ ResumeExperienceBullet[] bullets = await experienceBulletsTask;
+ ResumeMilitary? military = await militaryTask;
+ ResumeMilitaryBullet[] militaryBullets = await militaryBulletsTask;
+ ResumeEducation[] education = await educationTask;
+ ResumeSkill[] skills = await skillsTask;
+ ResumeLanguage[] languages = await languagesTask;
+ ResumeCertification[] certs = await certificationTask;
+ ResumeProject[] projects = await projectsTask;
- // Run the commands
- Task ResumeReader = resumeCommand.ExecuteReaderAsync();
- Task ResumeExperienceReader = ResumeExperienceCommand.ExecuteReaderAsync();
- Task ResumeExperienceBulletReader = ResumeExperienceBulletCommand.ExecuteReaderAsync();
- Task ResumeMilitaryReader = ResumeMilitaryCommand.ExecuteReaderAsync();
- Task ResumeMilitaryBulletReader = ResumeMilitaryBulletCommand.ExecuteReaderAsync();
- Task ResumeEducationReader = ResumeEducationCommand.ExecuteReaderAsync();
- Task ResumeSkillReader = ResumeSkillCommand.ExecuteReaderAsync();
- Task ResumeLanguageReader = ResumeLanguageCommand.ExecuteReaderAsync();
- Task ResumeCertificationReader = ResumeCertificationCommand.ExecuteReaderAsync();
- Task 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 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)];
+ Dictionary groupedExperienceBullets = bullets.GroupBy(b => Convert.ToInt32(b.ResumeExperienceID)).ToDictionary(g => g.Key, g => g.ToArray());
+ foreach (var exp in experience) {
+ exp.ExperienceBullets = groupedExperienceBullets.TryGetValue(Convert.ToInt32(exp.ID), out var b) ? b : Array.Empty();
}
- // Add the parts to the resume
- if (military != null) {
- military.MillitaryBullets = militaryBullets;
- resume.Millitary = military;
- }
- resume.Experience = experience;
+ resume.Experiences = experience;
resume.Educations = education;
resume.Skills = skills;
resume.Languages = languages;
- resume.Certification = certs;
+ resume.Certifications = certs;
resume.Projects = projects;
+ if (military != null) {
+ military.MilitaryBullets = militaryBullets;
+ resume.Military = military;
+ }
+
return resume;
}
- return null;
}
public async Task SetResume(Resume resume) {
-
- // Open connections for multi-threaded request
- MySqlConnection resumeConnection = GetConnection();
- 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
- Task resumeopen = resumeConnection.OpenAsync();
- Task resumeexperienceopen = ResumeExperienceConnection.OpenAsync();
- 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
- await Task.WhenAll(resumeopen, resumeexperienceopen, resumeexperiencebulletopen, resumemilitaryopen, resumemilitarybulletopen,
- resumeeducationopen, resumeskillopen, resumelanguageopen, resumecertifcationopen, resumeprojectopen);
-
- // Get all the experience bullets and run all the updates
- List bullets = new List();
- foreach (ResumeExperience cur in resume.Experience) {
- foreach (ResumeExperienceBullet bullet in cur.ExperienceBullets) {
- bullets.Add(bullet);
+ // Set ResumeID on all nodes
+ int _ResumeID = await SetResumeHeader(resume);
+ if (resume.Military != null) {
+ resume.Military.ResumeID = _ResumeID;
+ foreach (ResumeMilitaryBullet cur in resume.Military.MilitaryBullets) {
+ cur.ResumeID = _ResumeID;
+ }
+ }
+ foreach (ResumeEducation cur in resume.Educations) { cur.ResumeID = _ResumeID; }
+ foreach (ResumeSkill cur in resume.Skills) { cur.ResumeID = _ResumeID; }
+ foreach (ResumeLanguage cur in resume.Languages) { cur.ResumeID = _ResumeID; }
+ foreach (ResumeCertification cur in resume.Certifications) { cur.ResumeID = _ResumeID; }
+ foreach (ResumeProject cur in resume.Projects) { cur.ResumeID = _ResumeID; }
+ foreach (ResumeExperience cur in resume.Experiences) {
+ cur.ResumeID = _ResumeID;
+ foreach (ResumeExperienceBullet us in cur.ExperienceBullets) {
+ us.ResumeID = _ResumeID;
}
}
- 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
- await Task.WhenAll(ResumeTask, ResumeExperienceTask, ResumeExperienceBulletTask, ResumeMilitaryTask, ResumeMilitaryBulletTask,
- ResumeEducationTask, ResumeSkllTask, ResumeLanguageTask, ResumeCertTask, ResumeProjectTask);
+ // Async process all non child node SQL sets
+ Task[] tasks = [
+ 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> experienceTasks = new List>();
+ 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 experienceBulletTasks = new List();
+ 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 ) {
diff --git a/src/Server/Services/DatabaseService/ResumeParts/GetResumeParts.cs b/src/Server/Services/DatabaseService/ResumeParts/GetResumeParts.cs
index 016556d..a4c9d7a 100644
--- a/src/Server/Services/DatabaseService/ResumeParts/GetResumeParts.cs
+++ b/src/Server/Services/DatabaseService/ResumeParts/GetResumeParts.cs
@@ -1,248 +1,310 @@
using BoredCareers.Entities;
+using MySql.Data.MySqlClient;
using System.Data;
using System.Data.Common;
namespace BoredCareers.Services.DatabaseService {
public partial class DatabaseService {
- public async Task GetResume(DbDataReader reader) {
- while (await reader.ReadAsync()) {
- if (reader == null) { break; }
- int _id = reader.GetInt32("ID");
- int _accountid = reader.GetInt32("AccountID");
- string _title = reader.GetString("Title");
- string _name = reader.GetString("Name");
- string _field = reader.GetString("Field");
- string _email = reader.GetString("Email");
- string _phonenumber = reader.GetString("PhoneNumber");
- string _postalcode = reader.GetString("PostalCode");
- string _country = reader.GetString("Country");
- string _state = reader.GetString("StateOrRegion");
- string _city = reader.GetString("City");
- bool _isactive = reader.GetBoolean("IsActive");
- return new Resume() {
- ID = _id,
- AccountID = _accountid,
- Title = _title,
- Name = _name,
- Field = _field,
- Email = _email,
- PhoneNumber = _phonenumber,
- PostalCode = _postalcode,
- Country = _country,
- StateOrRegion = _state,
- City = _city,
- IsActive = _isactive
- };
+ string GetString(DbDataReader reader, string name) {
+ return reader.IsDBNull(reader.GetOrdinal(name)) ? "" : reader.GetString(name);
+ }
+
+ public async Task 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()) {
+ int _id = reader.GetInt32("ID");
+ int _accountid = reader.GetInt32("AccountID");
+ string _title = GetString(reader, "Title");
+ string _name = GetString(reader, "Name");
+ string _field = GetString(reader, "Field");
+ string _email = GetString(reader, "Email");
+ string _phonenumber = GetString(reader, "PhoneNumber");
+ string _postalcode = GetString(reader, "PostalCode");
+ string _country = GetString(reader, "Country");
+ string _state = GetString(reader, "StateOrRegion");
+ string _city = GetString(reader, "City");
+ bool _isactive = reader.GetBoolean("IsActive");
+ return new Resume() {
+ ID = _id,
+ AccountID = _accountid,
+ Title = _title,
+ Name = _name,
+ Field = _field,
+ Email = _email,
+ PhoneNumber = _phonenumber,
+ PostalCode = _postalcode,
+ Country = _country,
+ StateOrRegion = _state,
+ City = _city,
+ IsActive = _isactive
+ };
+ }
+ }
}
return null;
}
- public async Task GetResumeExperienceBullets(DbDataReader reader) {
- List experienceBullets = new List();
- 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 GetResumeExperience(DbDataReader reader) {
+ public async Task GetResumeExperience(int resumeId) {
List experience = new List();
- while (await reader.ReadAsync()) {
- if (reader == null) { break; }
- int _id = reader.GetInt32("ID");
- int _resumeid = reader.GetInt32("ResumeID");
- string _jobtitle = reader.GetString("JobTitle");
- string _company = reader.GetString("Company");
- string _postalcode = reader.GetString("PostalCode");
- string _country = reader.GetString("Country");
- string _state = reader.GetString("StateOrRegion");
- string _city = reader.GetString("City");
- DateTime _datestarted = reader.GetDateTime("DateStarted");
- bool _stillempoyed = reader.GetBoolean("StillEmployed");
- DateTime _dateended = reader.GetDateTime("DateEnded");
- experience.Add(new ResumeExperience() {
- ID = _id,
- ResumeID = _resumeid,
- JobTitle = _jobtitle,
- Company = _company,
- PostalCode = _postalcode,
- Country = _country,
- StateOrRegion = _state,
- City = _city,
- DateStarted = _datestarted,
- StillEmployed = _stillempoyed,
- DateEnded = _dateended,
- });
+ 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()) {
+ int _id = reader.GetInt32("ID");
+ int _resumeid = reader.GetInt32("ResumeID");
+ string _jobtitle = GetString(reader, "JobTitle");
+ string _company = GetString(reader, "Company");
+ string _postalcode = GetString(reader, "PostalCode");
+ string _country = GetString(reader, "Country");
+ string _state = GetString(reader, "StateOrRegion");
+ string _city = GetString(reader, "City");
+ DateTime _datestarted = reader.GetDateTime("DateStarted");
+ bool _stillempoyed = reader.GetBoolean("StillEmployed");
+ DateTime _dateended = reader.GetDateTime("DateEnded");
+ experience.Add(new ResumeExperience() {
+ ID = _id,
+ ResumeID = _resumeid,
+ JobTitle = _jobtitle,
+ Company = _company,
+ PostalCode = _postalcode,
+ Country = _country,
+ StateOrRegion = _state,
+ City = _city,
+ DateStarted = _datestarted,
+ StillEmployed = _stillempoyed,
+ DateEnded = _dateended,
+ });
+ }
+ }
}
return experience.ToArray();
}
- public async Task GetResumeMilitaryBullets(DbDataReader reader) {
+ public async Task GetResumeExperienceBullets(int resumeId) {
+ List experienceBullets = new List();
+ 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 GetResumeMilitaryBullets(int resumeId) {
List militaryBullets = new List();
- while (await reader.ReadAsync()) {
- if (reader == null) { break; }
- int _id = reader.GetInt32("ID");
- int _resumeid = reader.GetInt32("ResumeID");
- int _experienceid = reader.GetInt32("ResumeMilitaryID");
- string _achievement = reader.GetString("Achievement");
- string _description = reader.GetString("Description");
- militaryBullets.Add(new ResumeMilitaryBullet() {
- ID = _id,
- ResumeID = _resumeid,
- ResumeMilitaryID = _experienceid,
- Achievement = _achievement,
- Description = _description
- });
+ 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()) {
+ int _id = reader.GetInt32("ID");
+ int _resumeid = reader.GetInt32("ResumeID");
+ int _experienceid = reader.GetInt32("ResumeMilitaryID");
+ string _achievement = GetString(reader, "Achievement");
+ string _description = GetString(reader, "Description");
+ militaryBullets.Add(new ResumeMilitaryBullet() {
+ ID = _id,
+ ResumeID = _resumeid,
+ ResumeMilitaryID = _experienceid,
+ Achievement = _achievement,
+ Description = _description
+ });
+ }
+ }
}
return militaryBullets.ToArray();
}
- public async Task GetResumeMilitary(DbDataReader reader) {
+ public async Task GetResumeMilitary(int resumeId) {
ResumeMilitary? military = null;
- while (await reader.ReadAsync()) {
- if (reader == null) { break; }
- int _id = reader.GetInt32("ID");
- int _resumeid = reader.GetInt32("ResumeID");
- bool _veteran = reader.GetBoolean("Veteran");
- string _country = reader.GetString("Country");
- string _rank = reader.GetString("Rank");
- DateTime _datestarted = reader.GetDateTime("DateStarted");
- bool _stillServing = reader.GetBoolean("StillServing");
- DateTime _dateended = reader.GetDateTime("DateEnded");
- military = new ResumeMilitary() {
- ID = _id,
- ResumeID = _resumeid,
- Veteran = _veteran,
- Country = _country,
- Rank = _rank,
- DateStarted = _datestarted,
- StillServing = _stillServing,
- DateEnded = _dateended,
- };
+ 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()) {
+ int _id = reader.GetInt32("ID");
+ int _resumeid = reader.GetInt32("ResumeID");
+ string _country = GetString(reader, "Country");
+ string _rank = GetString(reader, "Rank");
+ DateTime _datestarted = reader.GetDateTime("DateStarted");
+ bool _stillServing = reader.GetBoolean("StillServing");
+ DateTime _dateended = reader.GetDateTime("DateEnded");
+ military = new ResumeMilitary() {
+ ID = _id,
+ ResumeID = _resumeid,
+ Country = _country,
+ Rank = _rank,
+ DateStarted = _datestarted,
+ StillServing = _stillServing,
+ DateEnded = _dateended,
+ };
+ }
+ }
}
return military;
}
- public async Task GetResumeEducation(DbDataReader reader) {
+ public async Task GetResumeEducation(int resumeId) {
List? education = new List();
- while (await reader.ReadAsync()) {
- if (reader == null) { break; }
- int _id = reader.GetInt32("ID");
- int _resumeid = reader.GetInt32("ResumeID");
- string _degreetype = reader.GetString("DegreeType");
- string _degreefield = reader.GetString("DegreeField");
- string _school = reader.GetString("School");
- string _postalcode = reader.GetString("PostalCode");
- string _country = reader.GetString("Country");
- string _state = reader.GetString("StateOrRegion");
- string _city = reader.GetString("City");
- DateTime _datestarted = reader.GetDateTime("DateStarted");
- bool _stillstudying = reader.GetBoolean("StillStudying");
- DateTime _dateended = reader.GetDateTime("DateEnded");
- education.Add(new ResumeEducation {
- ID = _id,
- ResumeID = _resumeid,
- DegreeType = _degreetype,
- DegreeField = _degreefield,
- School = _school,
- PostalCode = _postalcode,
- Country = _country,
- StateOrRegion = _state,
- City = _city,
- DateStarted = _datestarted,
- StillStudying = _stillstudying,
- DateEnded = _dateended
- });
+ 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()) {
+ int _id = reader.GetInt32("ID");
+ int _resumeid = reader.GetInt32("ResumeID");
+ string _degreetype = GetString(reader, "DegreeType");
+ string _degreefield = GetString(reader, "DegreeField");
+ string _school = GetString(reader, "School");
+ string _postalcode = GetString(reader, "PostalCode");
+ string _country = GetString(reader, "Country");
+ string _state = GetString(reader, "StateOrRegion");
+ string _city = GetString(reader, "City");
+ DateTime _datestarted = reader.GetDateTime("DateStarted");
+ bool _stillstudying = reader.GetBoolean("StillStudying");
+ DateTime _dateended = reader.GetDateTime("DateEnded");
+ education.Add(new ResumeEducation {
+ ID = _id,
+ ResumeID = _resumeid,
+ DegreeType = _degreetype,
+ DegreeField = _degreefield,
+ School = _school,
+ PostalCode = _postalcode,
+ Country = _country,
+ StateOrRegion = _state,
+ City = _city,
+ DateStarted = _datestarted,
+ StillStudying = _stillstudying,
+ DateEnded = _dateended
+ });
+ }
+ }
}
return education.ToArray();
}
- public async Task GetResumeSkills(DbDataReader reader) {
+ public async Task GetResumeSkills(int resumeId) {
List skills = new List();
- while (await reader.ReadAsync()) {
- if (reader == null) { break; }
- int _id = reader.GetInt32("ID");
- int _resumeid = reader.GetInt32("ResumeID");
- string _name = reader.GetString("Name");
- string _description = reader.GetString("Description");
- skills.Add( new ResumeSkill {
- ID = _id,
- ResumeID = _resumeid,
- Name = _name,
- Description = _description
- } );
+ 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()) {
+ int _id = reader.GetInt32("ID");
+ int _resumeid = reader.GetInt32("ResumeID");
+ string _name = GetString(reader, "Name");
+ string _description = GetString(reader, "Description");
+ skills.Add(new ResumeSkill {
+ ID = _id,
+ ResumeID = _resumeid,
+ Name = _name,
+ Description = _description
+ });
+ }
+ }
}
return skills.ToArray();
}
- public async Task GetResumeLanguages(DbDataReader reader) {
+ public async Task GetResumeLanguages(int resumeId) {
List? languages = new List();
- while (await reader.ReadAsync()) {
- if (reader == null) { break; }
- int _id = reader.GetInt32("ID");
- int _resumeid = reader.GetInt32("ResumeID");
- string _language = reader.GetString("Language");
- string _proficiency = reader.GetString("Proficiency");
- languages.Add( new ResumeLanguage {
- ID = _id,
- ResumeID = _resumeid,
- Language = _language,
- Proficiency = _proficiency
- } );
+ 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()) {
+ int _id = reader.GetInt32("ID");
+ int _resumeid = reader.GetInt32("ResumeID");
+ string _language = GetString(reader, "Language");
+ string _proficiency = GetString(reader, "Proficiency");
+ languages.Add(new ResumeLanguage {
+ ID = _id,
+ ResumeID = _resumeid,
+ Language = _language,
+ Proficiency = _proficiency
+ });
+ }
+ }
}
return languages.ToArray();
}
- public async Task GetResumeCertification(DbDataReader reader) {
+ public async Task GetResumeCertification(int resumeId) {
List certs = new List();
- while (await reader.ReadAsync()) {
- if (reader == null) { break; }
- int _id = reader.GetInt32("ID");
- int _resumeid = reader.GetInt32("ResumeID");
- string _name = reader.GetString("Name");
- string _url = reader.GetString("VerificationURL");
- string _description = reader.GetString("Description");
- certs.Add( new ResumeCertification {
- ID = _id,
- ResumeID = _resumeid,
- Name = _name,
- VerificationURL = _url,
- Description = _description
- } );
+ 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()) {
+ int _id = reader.GetInt32("ID");
+ int _resumeid = reader.GetInt32("ResumeID");
+ string _name = GetString(reader, "Name");
+ string _url = GetString(reader, "VerificationURL");
+ string _description = GetString(reader, "Description");
+ certs.Add(new ResumeCertification {
+ ID = _id,
+ ResumeID = _resumeid,
+ Name = _name,
+ VerificationURL = _url,
+ Description = _description
+ });
+ }
+ }
}
return certs.ToArray();
}
- public async Task GetResumeProjects(DbDataReader reader) {
+ public async Task GetResumeProjects(int resumeId) {
List? projects = new List();
- while (await reader.ReadAsync()) {
- if (reader == null) { break; }
- int _id = reader.GetInt32("ID");
- int _resumeid = reader.GetInt32("ResumeID");
- string _name = reader.GetString("Name");
- string _url = reader.GetString("URL");
- string _description = reader.GetString("Description");
- projects.Add( new ResumeProject {
- ID = _id,
- ResumeID = _resumeid,
- Name = _name,
- URL = _url,
- Description = _description
- } );
+ 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()) {
+ int _id = reader.GetInt32("ID");
+ int _resumeid = reader.GetInt32("ResumeID");
+ string _name = GetString(reader, "Name");
+ string _url = GetString(reader, "URL");
+ string _description = GetString(reader, "Description");
+ projects.Add(new ResumeProject {
+ ID = _id,
+ ResumeID = _resumeid,
+ Name = _name,
+ URL = _url,
+ Description = _description
+ });
+ }
+ }
}
return projects.ToArray();
}
-
}
}
diff --git a/src/Server/Services/DatabaseService/ResumeParts/SetResumeParts.cs b/src/Server/Services/DatabaseService/ResumeParts/SetResumeParts.cs
index 85c993d..2c4833e 100644
--- a/src/Server/Services/DatabaseService/ResumeParts/SetResumeParts.cs
+++ b/src/Server/Services/DatabaseService/ResumeParts/SetResumeParts.cs
@@ -4,47 +4,59 @@ using MySql.Data.MySqlClient;
namespace BoredCareers.Services.DatabaseService {
public partial class DatabaseService {
- public async Task SetResume(MySqlConnection connection, Resume resume) {
- string command = @"
- INSERT INTO Resume
- (ID,AccountID,Title,Name,Field,Email,PhoneNumber,PostalCode,Country,StateOrRegion,City,IsActive)
- VALUES
- (@ID,@AccountID,@Title,@Name,@Field,@Email,@PhoneNumber,@PostalCode,@Country,@StateOrRegion,@City,@IsActive)
- ON DUPLICATE KEY UPDATE
- AccountID = @AccountID,
- Title = @Title,
- Name = @Name,
- Field = @Field,
- Email = @Email,
- PhoneNumber = @PhoneNumber,
- PostalCode = @PostalCode,
- Country = @Country,
- StateOrRegion = @StateOrRegion,
- City = @City,
- IsActive = @IsActive;
- ";
-
- MySqlCommand cmd = new MySqlCommand(command, connection);
- cmd.Parameters.AddWithValue("@ID", resume.ID);
- cmd.Parameters.AddWithValue("@AccountID", resume.AccountID);
- cmd.Parameters.AddWithValue("@Title", resume.Title);
- cmd.Parameters.AddWithValue("@Name", resume.Name);
- cmd.Parameters.AddWithValue("@Field", resume.Field);
- cmd.Parameters.AddWithValue("@Email", resume.Email);
- cmd.Parameters.AddWithValue("@PhoneNumber", resume.PhoneNumber);
- cmd.Parameters.AddWithValue("@PostalCode", resume.PostalCode);
- cmd.Parameters.AddWithValue("@Country", resume.Country);
- cmd.Parameters.AddWithValue("@StateOrRegion", resume.StateOrRegion);
- cmd.Parameters.AddWithValue("@City", resume.City);
- cmd.Parameters.AddWithValue("@IsActive", resume.IsActive);
-
- await cmd.ExecuteNonQueryAsync();
- }
-
- public async Task SetResumeExperienceBullets(MySqlConnection connection, ResumeExperienceBullet[] bullets) {
- foreach (ResumeExperienceBullet cur in bullets) {
+ public async Task SetResumeHeader(Resume resume) {
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
string command = @"
INSERT INTO Resume
+ (ID,AccountID,Title,Name,Field,Email,PhoneNumber,PostalCode,Country,StateOrRegion,City,IsActive)
+ VALUES
+ (@ID,@AccountID,@Title,@Name,@Field,@Email,@PhoneNumber,@PostalCode,@Country,@StateOrRegion,@City,@IsActive)
+ ON DUPLICATE KEY UPDATE
+ AccountID = @AccountID,
+ Title = @Title,
+ Name = @Name,
+ Field = @Field,
+ Email = @Email,
+ PhoneNumber = @PhoneNumber,
+ PostalCode = @PostalCode,
+ Country = @Country,
+ StateOrRegion = @StateOrRegion,
+ City = @City,
+ IsActive = @IsActive;
+
+ SELECT LAST_INSERT_ID();
+ ";
+
+ MySqlCommand cmd = new MySqlCommand(command, conn);
+ cmd.Parameters.AddWithValue("@ID", resume.ID);
+ cmd.Parameters.AddWithValue("@AccountID", resume.AccountID);
+ cmd.Parameters.AddWithValue("@Title", resume.Title);
+ cmd.Parameters.AddWithValue("@Name", resume.Name);
+ cmd.Parameters.AddWithValue("@Field", resume.Field);
+ cmd.Parameters.AddWithValue("@Email", resume.Email);
+ cmd.Parameters.AddWithValue("@PhoneNumber", resume.PhoneNumber);
+ cmd.Parameters.AddWithValue("@PostalCode", resume.PostalCode);
+ cmd.Parameters.AddWithValue("@Country", resume.Country);
+ cmd.Parameters.AddWithValue("@StateOrRegion", resume.StateOrRegion);
+ cmd.Parameters.AddWithValue("@City", resume.City);
+ cmd.Parameters.AddWithValue("@IsActive", resume.IsActive);
+ object? result = await cmd.ExecuteScalarAsync();
+
+ if (resume.ID != null && resume.ID != 0) {
+ return Convert.ToInt32(resume.ID);
+ } else {
+ cmd.CommandText = "";
+ return Convert.ToInt32(result);
+ }
+ }
+ }
+
+ public async Task SetResumeExperienceBullets(ResumeExperienceBullet bullet) {
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
+ string command = @"
+ INSERT INTO ResumeExperienceBullet
(ID,ResumeID,ResumeExperienceID,JobFunction)
VALUES
(@ID,@ResumeID,@ResumeExperienceID,@JobFunction)
@@ -54,20 +66,21 @@ namespace BoredCareers.Services.DatabaseService {
JobFunction = @JobFunction;
";
- MySqlCommand cmd = new MySqlCommand(command, connection);
- cmd.Parameters.AddWithValue("@ID", cur.ID);
- cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
- cmd.Parameters.AddWithValue("@ResumeExperienceID", cur.ResumeExperienceID);
- cmd.Parameters.AddWithValue("@JobFunction", cur.JobFunction);
+ MySqlCommand cmd = new MySqlCommand(command, conn);
+ cmd.Parameters.AddWithValue("@ID", bullet.ID);
+ cmd.Parameters.AddWithValue("@ResumeID", bullet.ResumeID);
+ cmd.Parameters.AddWithValue("@ResumeExperienceID", bullet.ResumeExperienceID);
+ cmd.Parameters.AddWithValue("@JobFunction", bullet.JobFunction);
await cmd.ExecuteNonQueryAsync();
}
}
- public async Task SetResumeExperience(MySqlConnection connection, ResumeExperience[] experiences) {
- foreach (ResumeExperience cur in experiences) {
+ public async Task SetResumeExperience(ResumeExperience experiences) {
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
string command = @"
- INSERT INTO Resume
+ INSERT INTO ResumeExperience
(ID,ResumeID,JobTitle,Company,PostalCode,Country,StateOrRegion,City,DateStarted,StillEmployed,DateEnded)
VALUES
(@ID,@ResumeID,@JobTitle,@Company,@PostalCode,@Country,@StateOrRegion,@City,@DateStarted,@StillEmployed,@DateEnded)
@@ -82,208 +95,245 @@ namespace BoredCareers.Services.DatabaseService {
DateStarted = @DateStarted,
StillEmployed = @StillEmployed,
DateEnded = @DateEnded;
+
+ SELECT LAST_INSERT_ID();
";
- MySqlCommand cmd = new MySqlCommand(command, connection);
- cmd.Parameters.AddWithValue("@ID", cur.ID);
- cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
- cmd.Parameters.AddWithValue("@JobTitle", cur.JobTitle);
- cmd.Parameters.AddWithValue("@Company", cur.Company);
- cmd.Parameters.AddWithValue("@PostalCode", cur.PostalCode);
- cmd.Parameters.AddWithValue("@DateStarted", cur.DateStarted.ToUniversalTime());
- cmd.Parameters.AddWithValue("@StillEmployed", cur.StillEmployed);
- cmd.Parameters.AddWithValue("@DateEnded", cur.DateEnded.ToUniversalTime());
+ MySqlCommand cmd = new MySqlCommand(command, conn);
+ cmd.Parameters.AddWithValue("@ID", experiences.ID);
+ cmd.Parameters.AddWithValue("@ResumeID", experiences.ResumeID);
+ cmd.Parameters.AddWithValue("@JobTitle", experiences.JobTitle);
+ cmd.Parameters.AddWithValue("@Company", experiences.Company);
+ cmd.Parameters.AddWithValue("@Country", experiences.Country);
+ cmd.Parameters.AddWithValue("@StateOrRegion", experiences.StateOrRegion);
+ cmd.Parameters.AddWithValue("@City", experiences.City);
+ 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) {
- foreach (ResumeMilitaryBullet cur in bullets) {
- string command = @"
- INSERT INTO Resume
- (ID,ResumeID,ResumeMilitaryID,Achievement)
- VALUES
- (@ID,@ResumeID,@ResumeMilitaryID,@Achievement)
- ON DUPLICATE KEY UPDATE
- ResumeID = @ResumeID,
- ResumeMilitaryID = @ResumeMilitaryID,
- Achievement = @Achievement,
- Description = @Description;
- ";
+ public async Task SetResumeMilitaryBullets(ResumeMilitaryBullet[] bullets) {
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
+ foreach (ResumeMilitaryBullet cur in bullets) {
+ string command = @"
+ INSERT INTO ResumeMilitaryBullet
+ (ID,ResumeID,ResumeMilitaryID,Achievement)
+ VALUES
+ (@ID,@ResumeID,@ResumeMilitaryID,@Achievement)
+ ON DUPLICATE KEY UPDATE
+ ResumeID = @ResumeID,
+ ResumeMilitaryID = @ResumeMilitaryID,
+ Achievement = @Achievement,
+ Description = @Description;
+ ";
- MySqlCommand cmd = new MySqlCommand(command, connection);
- cmd.Parameters.AddWithValue("@ID", cur.ID);
- cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
- cmd.Parameters.AddWithValue("@ResumeMilitaryID", cur.ResumeMilitaryID);
- cmd.Parameters.AddWithValue("@Achievement", cur.Achievement);
- cmd.Parameters.AddWithValue("@Description", cur.Description);
+ MySqlCommand cmd = new MySqlCommand(command, conn);
+ cmd.Parameters.AddWithValue("@ID", cur.ID);
+ cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
+ cmd.Parameters.AddWithValue("@ResumeMilitaryID", cur.ResumeMilitaryID);
+ cmd.Parameters.AddWithValue("@Achievement", cur.Achievement);
+ cmd.Parameters.AddWithValue("@Description", cur.Description);
- await cmd.ExecuteNonQueryAsync();
+ await cmd.ExecuteNonQueryAsync();
+ }
}
}
- public async Task SetResumeMilitary(MySqlConnection connection, ResumeMilitary military) {
- string command = @"
- INSERT INTO Resume
- (ID,ResumeID,Veteran,Country,Rank,DateStarted,StillServing,DateEnded)
- VALUES
- (@ID,@ResumeID,@Veteran,@Country,@Rank,@DateStarted,@StillServing,@DateEnded)
- ON DUPLICATE KEY UPDATE
- ResumeID = @ResumeID,
- Veteran = @Veteran,
- Country = @Country,
- Rank = @Rank,
- DateStarted = @DateStarted,
- StillServing = @StillServing,
- DateEnded = @DateEnded;
- ";
+ public async Task SetResumeMilitary(ResumeMilitary? military) {
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
+ if (military != null) {
+ string command = @"
+ INSERT INTO ResumeMilitary
+ (ID,ResumeID,Country,`Rank`,DateStarted,StillServing,DateEnded)
+ VALUES
+ (@ID,@ResumeID,@Country,@Rank,@DateStarted,@StillServing,@DateEnded)
+ ON DUPLICATE KEY UPDATE
+ ResumeID = @ResumeID,
+ Country = @Country,
+ `Rank` = @Rank,
+ DateStarted = @DateStarted,
+ StillServing = @StillServing,
+ DateEnded = @DateEnded;
- MySqlCommand cmd = new MySqlCommand(command, connection);
- cmd.Parameters.AddWithValue("@ID", military.ID);
- cmd.Parameters.AddWithValue("@ResumeID", military.ResumeID);
- cmd.Parameters.AddWithValue("@Veteran", military.Veteran);
- cmd.Parameters.AddWithValue("@Country", military.Country);
- cmd.Parameters.AddWithValue("@Rank", military.Rank);
- cmd.Parameters.AddWithValue("@DateStarted", military.DateStarted.ToUniversalTime());
- cmd.Parameters.AddWithValue("@StillServing", military.StillServing);
- cmd.Parameters.AddWithValue("@DateEnded", military.DateEnded.ToUniversalTime());
+ SELECT LAST_INSERT_ID();
+ ";
- await cmd.ExecuteNonQueryAsync();
- }
+ MySqlCommand cmd = new MySqlCommand(command, conn);
+ cmd.Parameters.AddWithValue("@ID", military.ID);
+ cmd.Parameters.AddWithValue("@ResumeID", military.ResumeID);
+ cmd.Parameters.AddWithValue("@Country", military.Country);
+ cmd.Parameters.AddWithValue("@Rank", military.Rank);
+ cmd.Parameters.AddWithValue("@DateStarted", military.DateStarted.ToUniversalTime());
+ cmd.Parameters.AddWithValue("@StillServing", military.StillServing);
+ cmd.Parameters.AddWithValue("@DateEnded", military.DateEnded.ToUniversalTime());
+ object? result = await cmd.ExecuteScalarAsync();
- public async Task SetResumeEducation(MySqlConnection connection, ResumeEducation[] educations) {
- foreach (ResumeEducation cur in educations) {
- string command = @"
- INSERT INTO Resume
- (ID,ResumeID,DegreeType,DegreeField,School,PostalCode,Country,StateOrRegion,City,DateStarted,StillStudying,DateEnded)
- VALUES
- (@ID,@ResumeID,@DegreeType,@DegreeField,@School,@PostalCode,@Country,@StateOrRegion,@City,@DateStarted,@StillStudying,@DateEnded)
- ON DUPLICATE KEY UPDATE
- ResumeID = @ResumeID,
- DegreeType = @DegreeType,
- DegreeField = @DegreeField,
- School = @School,
- PostalCode = @PostalCode,
- Country = @Country,
- StateOrRegion = @StateOrRegion,
- City = @City,
- DateStarted = @DateStarted,
- StillStudying = @StillStudying,
- DateEnded = @DateEnded;
- ";
-
- MySqlCommand cmd = new MySqlCommand(command, connection);
- cmd.Parameters.AddWithValue("@ID", cur.ID);
- cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
- cmd.Parameters.AddWithValue("@DegreeType", cur.DegreeType);
- cmd.Parameters.AddWithValue("@DegreeField", cur.DegreeField);
- cmd.Parameters.AddWithValue("@School", cur.School);
- cmd.Parameters.AddWithValue("@PostalCode", cur.PostalCode);
- cmd.Parameters.AddWithValue("@Country", cur.Country);
- cmd.Parameters.AddWithValue("@StateOrRegion", cur.StateOrRegion);
- cmd.Parameters.AddWithValue("@City", cur.City);
- cmd.Parameters.AddWithValue("@DateStarted", cur.DateStarted.ToUniversalTime());
- cmd.Parameters.AddWithValue("@StillStudying", cur.StillStudying);
- cmd.Parameters.AddWithValue("@DateEnded", cur.DateEnded.ToUniversalTime());
-
- await cmd.ExecuteNonQueryAsync();
+ if (military.ID == null) {
+ military.ID = Convert.ToInt32(result);
+ }
+ return military;
+ }
+ return new ResumeMilitary();
}
}
- public async Task SetResumeSkills(MySqlConnection connection, ResumeSkill[] skills) {
- foreach (ResumeSkill cur in skills) {
- string command = @"
- INSERT INTO Resume
- (ID,ResumeID,Name,Description)
- VALUES
- (@ID,@ResumeID,@Name,@Description)
- ON DUPLICATE KEY UPDATE
- ResumeID = @ResumeID,
- Name = @Name,
- Description = @Description;
- ";
+ public async Task SetResumeEducation(ResumeEducation[] educations) {
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
+ foreach (ResumeEducation cur in educations) {
+ string command = @"
+ INSERT INTO ResumeEducation
+ (ID,ResumeID,DegreeType,DegreeField,School,PostalCode,Country,StateOrRegion,City,DateStarted,StillStudying,DateEnded)
+ VALUES
+ (@ID,@ResumeID,@DegreeType,@DegreeField,@School,@PostalCode,@Country,@StateOrRegion,@City,@DateStarted,@StillStudying,@DateEnded)
+ ON DUPLICATE KEY UPDATE
+ ResumeID = @ResumeID,
+ DegreeType = @DegreeType,
+ DegreeField = @DegreeField,
+ School = @School,
+ PostalCode = @PostalCode,
+ Country = @Country,
+ StateOrRegion = @StateOrRegion,
+ City = @City,
+ DateStarted = @DateStarted,
+ StillStudying = @StillStudying,
+ DateEnded = @DateEnded;
+ ";
- MySqlCommand cmd = new MySqlCommand(command, connection);
- cmd.Parameters.AddWithValue("@ID", cur.ID);
- cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
- cmd.Parameters.AddWithValue("@Name", cur.Name);
- cmd.Parameters.AddWithValue("@Description", cur.Description);
+ MySqlCommand cmd = new MySqlCommand(command, conn);
+ cmd.Parameters.AddWithValue("@ID", cur.ID);
+ cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
+ cmd.Parameters.AddWithValue("@DegreeType", cur.DegreeType);
+ cmd.Parameters.AddWithValue("@DegreeField", cur.DegreeField);
+ cmd.Parameters.AddWithValue("@School", cur.School);
+ cmd.Parameters.AddWithValue("@PostalCode", cur.PostalCode);
+ cmd.Parameters.AddWithValue("@Country", cur.Country);
+ cmd.Parameters.AddWithValue("@StateOrRegion", cur.StateOrRegion);
+ cmd.Parameters.AddWithValue("@City", cur.City);
+ cmd.Parameters.AddWithValue("@DateStarted", cur.DateStarted.ToUniversalTime());
+ cmd.Parameters.AddWithValue("@StillStudying", cur.StillStudying);
+ cmd.Parameters.AddWithValue("@DateEnded", cur.DateEnded.ToUniversalTime());
- await cmd.ExecuteNonQueryAsync();
+ await cmd.ExecuteNonQueryAsync();
+ }
}
}
- public async Task SetResumeLanguages(MySqlConnection connection, ResumeLanguage[] languages) {
- foreach (ResumeLanguage cur in languages) {
- string command = @"
- INSERT INTO Resume
- (ID,ResumeID,Language,Proficiency)
- VALUES
- (@ID,@ResumeID,@Language,@Proficiency)
- ON DUPLICATE KEY UPDATE
- ResumeID = @ResumeID,
- Language = @Language,
- Proficiency = @Proficiency;
- ";
+ public async Task SetResumeSkills(ResumeSkill[] skills) {
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
+ foreach (ResumeSkill cur in skills) {
+ string command = @"
+ INSERT INTO ResumeSkill
+ (ID,ResumeID,Name,Description)
+ VALUES
+ (@ID,@ResumeID,@Name,@Description)
+ ON DUPLICATE KEY UPDATE
+ ResumeID = @ResumeID,
+ Name = @Name,
+ Description = @Description;
+ ";
- MySqlCommand cmd = new MySqlCommand(command, connection);
- cmd.Parameters.AddWithValue("@ID", cur.ID);
- cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
- cmd.Parameters.AddWithValue("@Language", cur.Language);
- cmd.Parameters.AddWithValue("@Proficiency", cur.Proficiency);
+ MySqlCommand cmd = new MySqlCommand(command, conn);
+ cmd.Parameters.AddWithValue("@ID", cur.ID);
+ cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
+ cmd.Parameters.AddWithValue("@Name", cur.Name);
+ cmd.Parameters.AddWithValue("@Description", cur.Description);
- await cmd.ExecuteNonQueryAsync();
+ await cmd.ExecuteNonQueryAsync();
+ }
}
}
- public async Task SetResumeCertification(MySqlConnection connection, ResumeCertification[] certifications) {
- foreach (ResumeCertification cur in certifications) {
- string command = @"
- INSERT INTO Resume
- (ID,ResumeID,Name,VerificationURL,Description)
- VALUES
- (@ID,@ResumeID,@Name,@VerificationURL,@Description)
- ON DUPLICATE KEY UPDATE
- ResumeID = @ResumeID,
- Name = @DegreeNameType,
- VerificationURL = @VerificationURL,
- Description = @Description;
- ";
+ public async Task SetResumeLanguages(ResumeLanguage[] languages) {
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
+ foreach (ResumeLanguage cur in languages) {
+ string command = @"
+ INSERT INTO ResumeLanguage
+ (ID,ResumeID,Language,Proficiency)
+ VALUES
+ (@ID,@ResumeID,@Language,@Proficiency)
+ ON DUPLICATE KEY UPDATE
+ ResumeID = @ResumeID,
+ Language = @Language,
+ Proficiency = @Proficiency;
+ ";
- MySqlCommand cmd = new MySqlCommand(command, connection);
- cmd.Parameters.AddWithValue("@ID", cur.ID);
- cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
- cmd.Parameters.AddWithValue("@Name", cur.Name);
- cmd.Parameters.AddWithValue("@VerificationURL", cur.VerificationURL);
- cmd.Parameters.AddWithValue("@Description", cur.Description);
+ MySqlCommand cmd = new MySqlCommand(command, conn);
+ cmd.Parameters.AddWithValue("@ID", cur.ID);
+ cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
+ cmd.Parameters.AddWithValue("@Language", cur.Language);
+ cmd.Parameters.AddWithValue("@Proficiency", cur.Proficiency);
- await cmd.ExecuteNonQueryAsync();
+ await cmd.ExecuteNonQueryAsync();
+ }
}
}
- public async Task SetResumeProjects(MySqlConnection connection, ResumeProject[] projects) {
- foreach (ResumeProject cur in projects) {
- string command = @"
- INSERT INTO Resume
- (ID,ResumeID,Name,URL,Description)
- VALUES
- (@ID,@ResumeID,@Name,@URL,@Description)
- ON DUPLICATE KEY UPDATE
- ResumeID = @ResumeID,
- Name = @Name,
- URL = @URL,
- Description = @Description;
- ";
+ public async Task SetResumeCertification(ResumeCertification[] certifications) {
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
+ foreach (ResumeCertification cur in certifications) {
+ string command = @"
+ INSERT INTO ResumeCertification
+ (ID,ResumeID,Name,VerificationURL,Description)
+ VALUES
+ (@ID,@ResumeID,@Name,@VerificationURL,@Description)
+ ON DUPLICATE KEY UPDATE
+ ResumeID = @ResumeID,
+ Name = @Name,
+ VerificationURL = @VerificationURL,
+ Description = @Description;
+ ";
- MySqlCommand cmd = new MySqlCommand(command, connection);
- cmd.Parameters.AddWithValue("@ID", cur.ID);
- cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
- cmd.Parameters.AddWithValue("@Name", cur.Name);
- cmd.Parameters.AddWithValue("@URL", cur.URL);
- cmd.Parameters.AddWithValue("@Description", cur.Description);
+ MySqlCommand cmd = new MySqlCommand(command, conn);
+ cmd.Parameters.AddWithValue("@ID", cur.ID);
+ cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
+ cmd.Parameters.AddWithValue("@Name", cur.Name);
+ cmd.Parameters.AddWithValue("@VerificationURL", cur.VerificationURL);
+ cmd.Parameters.AddWithValue("@Description", cur.Description);
- await cmd.ExecuteNonQueryAsync();
+ await cmd.ExecuteNonQueryAsync();
+ }
+ }
+ }
+
+ public async Task SetResumeProjects(ResumeProject[] projects) {
+ using (var conn = GetConnection()) {
+ await conn.OpenAsync();
+ foreach (ResumeProject cur in projects) {
+ string command = @"
+ INSERT INTO ResumeProject
+ (ID,ResumeID,Name,URL,Description)
+ VALUES
+ (@ID,@ResumeID,@Name,@URL,@Description)
+ ON DUPLICATE KEY UPDATE
+ ResumeID = @ResumeID,
+ Name = @Name,
+ URL = @URL,
+ Description = @Description;
+ ";
+
+ MySqlCommand cmd = new MySqlCommand(command, conn);
+ cmd.Parameters.AddWithValue("@ID", cur.ID);
+ cmd.Parameters.AddWithValue("@ResumeID", cur.ResumeID);
+ cmd.Parameters.AddWithValue("@Name", cur.Name);
+ cmd.Parameters.AddWithValue("@URL", cur.URL);
+ cmd.Parameters.AddWithValue("@Description", cur.Description);
+
+ await cmd.ExecuteNonQueryAsync();
+ }
}
}