Work on DbDriver
This commit is contained in:
@@ -58,19 +58,42 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
public async Task<Resume?> GetResume(int ResumeID) {
|
public async Task<Resume?> GetResume(int ResumeID) {
|
||||||
Resume? resume = null;
|
Resume? resume = null;
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
|
||||||
|
|
||||||
connection.Open();
|
MySqlConnection resumeConnection = GetConnection();
|
||||||
MySqlCommand resumeCommand = new MySqlCommand("SELECT * FROM Resume WHERE ID = @ResumeID;", connection);
|
MySqlConnection ResumeExperienceConnection = GetConnection();
|
||||||
MySqlCommand ResumeExperienceCommand = new MySqlCommand("SELECT * FROM ResumeExperience WHERE ResumeID = @ResumeID;", connection);
|
MySqlConnection ResumeExperienceBulletConnection = GetConnection();
|
||||||
MySqlCommand ResumeExperienceBulletCommand = new MySqlCommand("SELECT * FROM ResumeExperienceBullet WHERE ResumeID = @ResumeID;");
|
MySqlConnection ResumeMilitaryConnection = GetConnection();
|
||||||
MySqlCommand ResumeMilitaryCommand = new MySqlCommand("SELECT * FROM ResumeMilitary WHERE ResumeID = @ResumeID;", connection);
|
MySqlConnection ResumeMilitaryBulletConnection = GetConnection();
|
||||||
MySqlCommand ResumeMilitaryBulletCommand = new MySqlCommand("SELECT * FROM ResumeMilitaryBullet WHERE ResumeID = @ResumeID", connection);
|
MySqlConnection ResumeEducationConnection = GetConnection();
|
||||||
MySqlCommand ResumeEducationCommand = new MySqlCommand("SELECT * FROM ResumeEducation WHERE ResumeID = @ResumeID;", connection);
|
MySqlConnection ResumeSkillConnection = GetConnection();
|
||||||
MySqlCommand ResumeSkillCommand = new MySqlCommand("SELECT * FROM ResumeSkill WHERE ResumeID = @ResumeID;", connection);
|
MySqlConnection ResumeLanguageConnection = GetConnection();
|
||||||
MySqlCommand ResumeLanguageCommand = new MySqlCommand("SELECT * FROM ResumeLanguage WHERE ResumeID = @ResumeID;", connection);
|
MySqlConnection ResumeCertificationConnection = GetConnection();
|
||||||
MySqlCommand ResumeCertificationCommand = new MySqlCommand("SELECT * FROM ResumeCertification WHERE ResumeID = @ResumeID;", connection);
|
MySqlConnection ResumeProjectConnection = GetConnection();
|
||||||
MySqlCommand ResumeProjectCommand = new MySqlCommand("SELECT * FROM ResumeProject WHERE ResumeID = @ResumeID;", connection);
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
await Task.WhenAll(resumeopen, resumeexperienceopen, resumeexperiencebulletopen, resumemilitaryopen, resumemilitarybulletopen,
|
||||||
|
resumeeducationopen, resumeskillopen, resumelanguageopen, resumecertifcationopen, resumeprojectopen);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
resumeCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
resumeCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
||||||
ResumeExperienceCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
ResumeExperienceCommand.Parameters.AddWithValue("@ResumeID", ResumeID);
|
||||||
@@ -94,14 +117,12 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
Task<DbDataReader> ResumeCertificationReader = ResumeCertificationCommand.ExecuteReaderAsync();
|
Task<DbDataReader> ResumeCertificationReader = ResumeCertificationCommand.ExecuteReaderAsync();
|
||||||
Task<DbDataReader> ResumeProjectnReader = ResumeProjectCommand.ExecuteReaderAsync();
|
Task<DbDataReader> ResumeProjectnReader = ResumeProjectCommand.ExecuteReaderAsync();
|
||||||
|
|
||||||
await Task.WhenAll(resumeReader, ResumeExperienceReader, ResumeExperienceBulletReader, ResumeMilitaryReader, ResumeMilitaryBulletReader, ResumeEducationReader, ResumeSkillReader, ResumeLanguageReader, ResumeCertificationReader, ResumeProjectnReader);
|
await Task.WhenAll(resumeReader, ResumeExperienceReader, ResumeExperienceBulletReader, ResumeMilitaryReader, ResumeMilitaryBulletReader,
|
||||||
|
ResumeEducationReader, ResumeSkillReader, ResumeLanguageReader, ResumeCertificationReader, ResumeProjectnReader);
|
||||||
|
|
||||||
using (DbDataReader reader = await resumeReader) {
|
using (DbDataReader reader = await resumeReader) {
|
||||||
while (await reader.ReadAsync()) {
|
while (await reader.ReadAsync()) {
|
||||||
if (reader == null) {
|
if (reader == null) { break; }
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _id = reader.GetInt32("ID");
|
int _id = reader.GetInt32("ID");
|
||||||
int _accountid = reader.GetInt32("AccountID");
|
int _accountid = reader.GetInt32("AccountID");
|
||||||
string _name = reader.GetString("Name");
|
string _name = reader.GetString("Name");
|
||||||
@@ -113,7 +134,6 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
string _state = reader.GetString("StateOrRegion");
|
string _state = reader.GetString("StateOrRegion");
|
||||||
string _city = reader.GetString("City");
|
string _city = reader.GetString("City");
|
||||||
bool _isactive = reader.GetBoolean("IsActive");
|
bool _isactive = reader.GetBoolean("IsActive");
|
||||||
|
|
||||||
resume = new Resume() {
|
resume = new Resume() {
|
||||||
ID = _id,
|
ID = _id,
|
||||||
AccountID = _accountid,
|
AccountID = _accountid,
|
||||||
@@ -130,11 +150,62 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (DbDataReader reader = await ResumeExperienceReader) {
|
List<ResumeExperienceBullet> experienceBullets = new List<ResumeExperienceBullet>();
|
||||||
|
using (DbDataReader reader = await ResumeExperienceBulletReader) {
|
||||||
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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()
|
||||||
|
} );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (DbDataReader reader = await ResumeExperienceBulletReader) {
|
using (DbDataReader reader = await ResumeMilitaryBulletReader) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,10 +213,6 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using (DbDataReader reader = await ResumeMilitaryBulletReader) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
using (DbDataReader reader = await ResumeEducationReader) {
|
using (DbDataReader reader = await ResumeEducationReader) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -165,7 +232,6 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
using (DbDataReader reader = await ResumeProjectnReader) {
|
using (DbDataReader reader = await ResumeProjectnReader) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return resume;
|
return resume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user