split out functions for readability
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using BoredCareers.Entities;
|
using BoredCareers.Entities;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
using Stripe.Terminal;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
|
|
||||||
@@ -57,8 +58,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Resume?> GetResume(int ResumeID) {
|
public async Task<Resume?> GetResume(int ResumeID) {
|
||||||
Resume? resume = null;
|
// Open connections for multi-threaded request
|
||||||
|
|
||||||
MySqlConnection resumeConnection = GetConnection();
|
MySqlConnection resumeConnection = GetConnection();
|
||||||
MySqlConnection ResumeExperienceConnection = GetConnection();
|
MySqlConnection ResumeExperienceConnection = GetConnection();
|
||||||
MySqlConnection ResumeExperienceBulletConnection = GetConnection();
|
MySqlConnection ResumeExperienceBulletConnection = GetConnection();
|
||||||
@@ -70,6 +70,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
MySqlConnection ResumeCertificationConnection = GetConnection();
|
MySqlConnection ResumeCertificationConnection = GetConnection();
|
||||||
MySqlConnection ResumeProjectConnection = GetConnection();
|
MySqlConnection ResumeProjectConnection = GetConnection();
|
||||||
|
|
||||||
|
// Open the connections
|
||||||
Task resumeopen = resumeConnection.OpenAsync();
|
Task resumeopen = resumeConnection.OpenAsync();
|
||||||
Task resumeexperienceopen = ResumeExperienceConnection.OpenAsync();
|
Task resumeexperienceopen = ResumeExperienceConnection.OpenAsync();
|
||||||
Task resumeexperiencebulletopen = ResumeExperienceBulletConnection.OpenAsync();
|
Task resumeexperiencebulletopen = ResumeExperienceBulletConnection.OpenAsync();
|
||||||
@@ -81,9 +82,11 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
Task resumecertifcationopen = ResumeCertificationConnection.OpenAsync();
|
Task resumecertifcationopen = ResumeCertificationConnection.OpenAsync();
|
||||||
Task resumeprojectopen = ResumeProjectConnection.OpenAsync();
|
Task resumeprojectopen = ResumeProjectConnection.OpenAsync();
|
||||||
|
|
||||||
|
// Wait for all the connections to open
|
||||||
await Task.WhenAll(resumeopen, resumeexperienceopen, resumeexperiencebulletopen, resumemilitaryopen, resumemilitarybulletopen,
|
await Task.WhenAll(resumeopen, resumeexperienceopen, resumeexperiencebulletopen, resumemilitaryopen, resumemilitarybulletopen,
|
||||||
resumeeducationopen, resumeskillopen, resumelanguageopen, resumecertifcationopen, resumeprojectopen);
|
resumeeducationopen, resumeskillopen, resumelanguageopen, resumecertifcationopen, resumeprojectopen);
|
||||||
|
|
||||||
|
// Setup the commands for the connections
|
||||||
MySqlCommand resumeCommand = new MySqlCommand("SELECT * FROM Resume WHERE ID = @ResumeID;", resumeConnection);
|
MySqlCommand resumeCommand = new MySqlCommand("SELECT * FROM Resume WHERE ID = @ResumeID;", resumeConnection);
|
||||||
MySqlCommand ResumeExperienceCommand = new MySqlCommand("SELECT * FROM ResumeExperience WHERE ResumeID = @ResumeID;", ResumeExperienceConnection);
|
MySqlCommand ResumeExperienceCommand = new MySqlCommand("SELECT * FROM ResumeExperience WHERE ResumeID = @ResumeID;", ResumeExperienceConnection);
|
||||||
MySqlCommand ResumeExperienceBulletCommand = new MySqlCommand("SELECT * FROM ResumeExperienceBullet WHERE ResumeID = @ResumeID;", ResumeExperienceBulletConnection);
|
MySqlCommand ResumeExperienceBulletCommand = new MySqlCommand("SELECT * FROM ResumeExperienceBullet WHERE ResumeID = @ResumeID;", ResumeExperienceBulletConnection);
|
||||||
@@ -95,6 +98,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
MySqlCommand ResumeCertificationCommand = new MySqlCommand("SELECT * FROM ResumeCertification WHERE ResumeID = @ResumeID;", ResumeCertificationConnection);
|
MySqlCommand ResumeCertificationCommand = new MySqlCommand("SELECT * FROM ResumeCertification WHERE ResumeID = @ResumeID;", ResumeCertificationConnection);
|
||||||
MySqlCommand ResumeProjectCommand = new MySqlCommand("SELECT * FROM ResumeProject WHERE ResumeID = @ResumeID;", ResumeProjectConnection);
|
MySqlCommand ResumeProjectCommand = new MySqlCommand("SELECT * FROM ResumeProject WHERE ResumeID = @ResumeID;", ResumeProjectConnection);
|
||||||
|
|
||||||
|
// Add parameters to the commands
|
||||||
resumeCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
resumeCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
||||||
ResumeExperienceCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
ResumeExperienceCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
||||||
ResumeExperienceBulletCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
ResumeExperienceBulletCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
||||||
@@ -106,7 +110,8 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
ResumeCertificationCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
ResumeCertificationCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
||||||
ResumeProjectCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
ResumeProjectCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
||||||
|
|
||||||
Task<DbDataReader> resumeReader = resumeCommand.ExecuteReaderAsync();
|
// Run the commands
|
||||||
|
Task<DbDataReader> ResumeReader = resumeCommand.ExecuteReaderAsync();
|
||||||
Task<DbDataReader> ResumeExperienceReader = ResumeExperienceCommand.ExecuteReaderAsync();
|
Task<DbDataReader> ResumeExperienceReader = ResumeExperienceCommand.ExecuteReaderAsync();
|
||||||
Task<DbDataReader> ResumeExperienceBulletReader = ResumeExperienceBulletCommand.ExecuteReaderAsync();
|
Task<DbDataReader> ResumeExperienceBulletReader = ResumeExperienceBulletCommand.ExecuteReaderAsync();
|
||||||
Task<DbDataReader> ResumeMilitaryReader = ResumeMilitaryCommand.ExecuteReaderAsync();
|
Task<DbDataReader> ResumeMilitaryReader = ResumeMilitaryCommand.ExecuteReaderAsync();
|
||||||
@@ -117,293 +122,100 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
Task<DbDataReader> ResumeCertificationReader = ResumeCertificationCommand.ExecuteReaderAsync();
|
Task<DbDataReader> ResumeCertificationReader = ResumeCertificationCommand.ExecuteReaderAsync();
|
||||||
Task<DbDataReader> ResumeProjectReader = ResumeProjectCommand.ExecuteReaderAsync();
|
Task<DbDataReader> ResumeProjectReader = ResumeProjectCommand.ExecuteReaderAsync();
|
||||||
|
|
||||||
await Task.WhenAll(resumeReader, ResumeExperienceReader, ResumeExperienceBulletReader, ResumeMilitaryReader, ResumeMilitaryBulletReader,
|
// Wait for all the commands to process
|
||||||
|
await Task.WhenAll(ResumeReader, ResumeExperienceReader, ResumeExperienceBulletReader, ResumeMilitaryReader, ResumeMilitaryBulletReader,
|
||||||
ResumeEducationReader, ResumeSkillReader, ResumeLanguageReader, ResumeCertificationReader, ResumeProjectReader);
|
ResumeEducationReader, ResumeSkillReader, ResumeLanguageReader, ResumeCertificationReader, ResumeProjectReader);
|
||||||
|
|
||||||
using (DbDataReader reader = await resumeReader) {
|
// Get Resume
|
||||||
while (await reader.ReadAsync()) {
|
Resume? resume = await GetResume( await ResumeReader );
|
||||||
if (reader == null) { break; }
|
if (resume != null) {
|
||||||
int _id = reader.GetInt32("ID");
|
|
||||||
int _accountid = reader.GetInt32("AccountID");
|
|
||||||
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");
|
|
||||||
resume = new Resume() {
|
|
||||||
ID = _id,
|
|
||||||
AccountID = _accountid,
|
|
||||||
Name = _name,
|
|
||||||
Field = _field,
|
|
||||||
Email = _email,
|
|
||||||
PhoneNumber = _phonenumber,
|
|
||||||
PostalCode = _postalcode,
|
|
||||||
Country = _country,
|
|
||||||
StateOrRegion = _state,
|
|
||||||
City = _city,
|
|
||||||
IsActive = _isactive
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resume == null) {
|
// Get Resume Parts
|
||||||
return resume;
|
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);
|
||||||
|
|
||||||
List<ResumeExperienceBullet> experienceBullets = new List<ResumeExperienceBullet>();
|
// Split into grouped lists and add to experience
|
||||||
using (DbDataReader reader = await ResumeExperienceBulletReader) {
|
Dictionary<int, ResumeExperienceBullet[]> groupedExperienceBullets = experienceBullets.GroupBy(b => b.ResumeExperienceID).ToDictionary(g => g.Key, g => g.ToArray());
|
||||||
while (await reader.ReadAsync()) {
|
foreach (ResumeExperience cur in experience) {
|
||||||
if (reader == null) { break; }
|
cur.ExperienceBullets = groupedExperienceBullets[cur.ID];
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Dictionary<int, List<ResumeExperienceBullet>> groupedExperienceBullets = experienceBullets
|
|
||||||
.GroupBy(b => b.ResumeExperienceID).ToDictionary(g => g.Key, g => g.ToList());
|
|
||||||
using (DbDataReader reader = await ResumeExperienceReader) {
|
|
||||||
List<ResumeExperience> experience = new List<ResumeExperience>();
|
|
||||||
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,
|
|
||||||
ExperienceBullets = groupedExperienceBullets[_id].ToArray()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
resume.Experience = experience.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ResumeMilitaryBullet> militaryBullets = new List<ResumeMilitaryBullet>();
|
// Add the parts to the resume
|
||||||
using (DbDataReader reader = await ResumeMilitaryBulletReader) {
|
|
||||||
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("Achevement");
|
|
||||||
string _description = reader.GetString("Description");
|
|
||||||
militaryBullets.Add(new ResumeMilitaryBullet() {
|
|
||||||
ID = _id,
|
|
||||||
ResumeID = _resumeid,
|
|
||||||
ResumeMilitaryID = _experienceid,
|
|
||||||
Achevement = _achievement,
|
|
||||||
Description = _description
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Dictionary<int, List<ResumeMilitaryBullet>> groupedMilitaryBullets = militaryBullets
|
|
||||||
.GroupBy(b => b.ResumeMilitaryID).ToDictionary(g => g.Key, g => g.ToList());
|
|
||||||
using (DbDataReader reader = await ResumeMilitaryReader) {
|
|
||||||
ResumeMilitary? military = null;
|
|
||||||
while (await reader.ReadAsync()) {
|
|
||||||
if (reader == null) { break; }
|
|
||||||
int _id = reader.GetInt32("ID");
|
|
||||||
int _resumeid = reader.GetInt32("ResumeID");
|
|
||||||
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,
|
|
||||||
Country = _country,
|
|
||||||
Rank = _rank,
|
|
||||||
DateStarted = _datestarted,
|
|
||||||
StillServing = _stillServing,
|
|
||||||
DateEnded = _dateended,
|
|
||||||
MillitaryBullets = groupedMilitaryBullets[_id].ToArray()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (military != null) {
|
if (military != null) {
|
||||||
|
military.MillitaryBullets = militaryBullets;
|
||||||
resume.Millitary = military;
|
resume.Millitary = military;
|
||||||
}
|
}
|
||||||
}
|
resume.Experience = experience;
|
||||||
|
resume.Educations = education;
|
||||||
|
resume.Skills = skills;
|
||||||
|
resume.Languages = languages;
|
||||||
|
resume.Certification = certs;
|
||||||
|
resume.Projects = projects;
|
||||||
|
|
||||||
using (DbDataReader reader = await ResumeEducationReader) {
|
return resume;
|
||||||
List<ResumeEducation>? education = new List<ResumeEducation>();
|
|
||||||
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
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
resume.Educations = education.ToArray();
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
using (DbDataReader reader = await ResumeSkillReader) {
|
|
||||||
List<ResumeSkill>? skills = new List<ResumeSkill>();
|
|
||||||
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
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
resume.Skills = skills.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
using (DbDataReader reader = await ResumeLanguageReader) {
|
|
||||||
List<ResumeLanguage>? languages = new List<ResumeLanguage>();
|
|
||||||
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
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
resume.Languages = languages.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
using (DbDataReader reader = await ResumeCertificationReader) {
|
|
||||||
List<ResumeCertification>? certs = new List<ResumeCertification>();
|
|
||||||
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
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
resume.Certification = certs.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
using (DbDataReader reader = await ResumeProjectReader) {
|
|
||||||
List<ResumeProject>? projects = new List<ResumeProject>();
|
|
||||||
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
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
resume.Projects = projects.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
return resume;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SetResume( Resume resume ) {
|
public async Task SetResume(Resume resume) {
|
||||||
using( MySqlConnection connection = GetConnection() ) {
|
|
||||||
connection.Open();
|
|
||||||
|
|
||||||
string command = @"
|
// Open connections for multi-threaded request
|
||||||
INSERT INTO Account
|
MySqlConnection resumeConnection = GetConnection();
|
||||||
(ID,UserName,Email,EmailVerified,PasswordHash,FailedPasswordLock,PasswordAttempts,CurrentPasswordAttempts,Role,EmailToken,DataServer)
|
MySqlConnection ResumeExperienceConnection = GetConnection();
|
||||||
VALUES
|
MySqlConnection ResumeExperienceBulletConnection = GetConnection();
|
||||||
(@ID,@UserName,@Email,@EmailVerified,@PasswordHash,@FailedPasswordLock,@PasswordAttempts,@CurrentPasswordAttempts,@Role,@EmailToken,@DataServer);
|
MySqlConnection ResumeMilitaryConnection = GetConnection();
|
||||||
ON DUPLICATE KEY UPDATE
|
MySqlConnection ResumeMilitaryBulletConnection = GetConnection();
|
||||||
UserName = @UserName,
|
MySqlConnection ResumeEducationConnection = GetConnection();
|
||||||
Email = @Email,
|
MySqlConnection ResumeSkillConnection = GetConnection();
|
||||||
EmailVerified = @EmailVerified,
|
MySqlConnection ResumeLanguageConnection = GetConnection();
|
||||||
PasswordHash = @PasswordHash,
|
MySqlConnection ResumeCertificationConnection = GetConnection();
|
||||||
FailedPasswordLock = @FailedPasswordLock,
|
MySqlConnection ResumeProjectConnection = GetConnection();
|
||||||
PasswordAttempts = @PasswordAttempts,
|
|
||||||
CurrentPasswordAttempts = @CurrentPasswordAttempts,
|
|
||||||
Role = @Role,
|
|
||||||
EmailToken = @EmailToken;
|
|
||||||
DataServer = @DataServer;
|
|
||||||
";
|
|
||||||
|
|
||||||
MySqlCommand cmd = new MySqlCommand( command , connection);
|
// Open the connections
|
||||||
cmd.Parameters.AddWithValue("@ID", Profile.ID);
|
Task resumeopen = resumeConnection.OpenAsync();
|
||||||
cmd.Parameters.AddWithValue("@UserName", Profile.UserName);
|
Task resumeexperienceopen = ResumeExperienceConnection.OpenAsync();
|
||||||
cmd.Parameters.AddWithValue("@Email", Profile.Email);
|
Task resumeexperiencebulletopen = ResumeExperienceBulletConnection.OpenAsync();
|
||||||
cmd.Parameters.AddWithValue("@EmailVerified", Profile.EmailVerified);
|
Task resumemilitaryopen = ResumeMilitaryConnection.OpenAsync();
|
||||||
cmd.Parameters.AddWithValue("@PasswordHash", Profile.PasswordHash);
|
Task resumemilitarybulletopen = ResumeMilitaryBulletConnection.OpenAsync();
|
||||||
cmd.Parameters.AddWithValue("@FailedPasswordLock", Profile.FailedPasswordLock);
|
Task resumeeducationopen = ResumeEducationConnection.OpenAsync();
|
||||||
cmd.Parameters.AddWithValue("@PasswordAttempts", Profile.PasswordAttempts);
|
Task resumeskillopen = ResumeSkillConnection.OpenAsync();
|
||||||
cmd.Parameters.AddWithValue("@CurrentPasswordAttempts", Profile.CurrentPasswordAttempts);
|
Task resumelanguageopen = ResumeLanguageConnection.OpenAsync();
|
||||||
cmd.Parameters.AddWithValue("@Role", Profile.Role);
|
Task resumecertifcationopen = ResumeCertificationConnection.OpenAsync();
|
||||||
cmd.Parameters.AddWithValue("@EmailToken", Profile.EmailToken);
|
Task resumeprojectopen = ResumeProjectConnection.OpenAsync();
|
||||||
cmd.Parameters.AddWithValue("@DataServer", Profile.DataServer);
|
|
||||||
|
|
||||||
await cmd.ExecuteNonQueryAsync();
|
// 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
|
||||||
|
await Task.WhenAll(ResumeTask, ResumeExperienceTask, ResumeExperienceBulletTask, ResumeMilitaryTask, ResumeMilitaryBulletTask,
|
||||||
|
ResumeEducationTask, ResumeSkllTask, ResumeLanguageTask, ResumeCertTask, ResumeProjectTask);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteResume( int ID ) {
|
public async Task DeleteResume( int ID ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user