Thread on the server better
This commit is contained in:
@@ -9,7 +9,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
public async Task<JobListing[]> GetJobListingPage(int PageNumber, int CountPerPage) {
|
||||
List<JobListing> joblistings = new List<JobListing>();
|
||||
using (MySqlConnection connection = GetConnection()) {
|
||||
connection.Open();
|
||||
await connection.OpenAsync();
|
||||
string command = @"
|
||||
SELECT *
|
||||
FROM JobListing
|
||||
@@ -24,7 +24,6 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
|
||||
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
||||
while (await reader.ReadAsync()) {
|
||||
if (reader == null) { break; }
|
||||
int _id = reader.GetInt32("ID");
|
||||
int _companyid = reader.GetInt32("CompanyID");
|
||||
string _title = reader.GetString("Title");
|
||||
@@ -69,7 +68,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
public async Task<JobListing[]> GetJobListingFromCompany(int CompanyID) {
|
||||
List<JobListing> joblistings = new List<JobListing>(); ;
|
||||
using (MySqlConnection connection = GetConnection()) {
|
||||
connection.Open();
|
||||
await connection.OpenAsync();
|
||||
string command = @"
|
||||
SELECT *
|
||||
FROM JobListing
|
||||
@@ -81,7 +80,6 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
|
||||
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
||||
while (await reader.ReadAsync()) {
|
||||
if (reader == null) { break; }
|
||||
int _id = reader.GetInt32("ID");
|
||||
int _companyid = reader.GetInt32("CompanyID");
|
||||
string _title = reader.GetString("Title");
|
||||
@@ -126,7 +124,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
public async Task<JobListing?> GetJobListing(int JobListingID) {
|
||||
JobListing? joblisting = null;
|
||||
using (MySqlConnection connection = GetConnection()) {
|
||||
connection.Open();
|
||||
await connection.OpenAsync();
|
||||
string command = @"
|
||||
SELECT *
|
||||
FROM JobListing
|
||||
@@ -138,7 +136,6 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
|
||||
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
||||
while (await reader.ReadAsync()) {
|
||||
if (reader == null) { break; }
|
||||
int _id = reader.GetInt32("ID");
|
||||
int _companyid = reader.GetInt32("CompanyID");
|
||||
string _title = reader.GetString("Title");
|
||||
@@ -180,9 +177,78 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
return joblisting;
|
||||
}
|
||||
|
||||
public async Task SetJobListing( JobListing jobListing ) {
|
||||
public async Task<JobListing[]> GetJobListingsPastExipre() {
|
||||
List<JobListing> joblistings = new List<JobListing>();
|
||||
using (MySqlConnection connection = GetConnection()) {
|
||||
connection.Open();
|
||||
await connection.OpenAsync();
|
||||
string command = @"
|
||||
SELECT *
|
||||
FROM JobListing
|
||||
WHERE IsDeleted = FALSE
|
||||
AND CreatedTime < NOW() - INTERVAL 1 MONTH;
|
||||
";
|
||||
MySqlCommand cmd = new MySqlCommand(command, connection);
|
||||
|
||||
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
||||
while (await reader.ReadAsync()) {
|
||||
int _id = reader.GetInt32("ID");
|
||||
int _companyid = reader.GetInt32("CompanyID");
|
||||
string _title = reader.GetString("Title");
|
||||
string _postalcode = reader.GetString("PostalCode");
|
||||
string _country = reader.GetString("Country");
|
||||
string _state = reader.GetString("StateOrRegion");
|
||||
string _city = reader.GetString("City");
|
||||
int _salarymin = reader.GetInt32("SalaryMin");
|
||||
int _salarymax = reader.GetInt32("SalaryMax");
|
||||
string _jobtype = reader.GetString("JobType");
|
||||
bool _remote = reader.GetBoolean("Remote");
|
||||
string _description = reader.GetString("Description");
|
||||
JobListingSkill[] _skills = await GetJobListingSkills(_id);
|
||||
DateTime _createtime = reader.GetDateTime("CreatedTime");
|
||||
DateTime _modifiedtime = reader.GetDateTime("ModifiedTime");
|
||||
bool _isdeleted = reader.GetBoolean("IsDeleted");
|
||||
|
||||
joblistings.Add(new JobListing() {
|
||||
ID = _id,
|
||||
CompanyID = _companyid,
|
||||
Title = _title,
|
||||
PostalCode = _postalcode,
|
||||
Country = _country,
|
||||
StateOrRegion = _state,
|
||||
City = _city,
|
||||
SalaryMin = _salarymin,
|
||||
SalaryMax = _salarymax,
|
||||
JobType = _jobtype,
|
||||
Remote = _remote,
|
||||
Description = _description,
|
||||
Skills = _skills,
|
||||
CreatedTime = _createtime,
|
||||
ModifiedTime = _modifiedtime,
|
||||
IsDeleted = _isdeleted
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return joblistings.ToArray();
|
||||
}
|
||||
|
||||
public async Task DeleteJobListingsPastExipre() {
|
||||
using (MySqlConnection connection = GetConnection()) {
|
||||
await connection.OpenAsync();
|
||||
string command = @"
|
||||
UPDATE JobListing
|
||||
SET IsDeleted = TRUE
|
||||
WHERE IsDeleted = FALSE
|
||||
AND CreatedTime < NOW() - INTERVAL 1 MONTH;
|
||||
";
|
||||
MySqlCommand cmd = new MySqlCommand(command, connection);
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetJobListing(JobListing jobListing) {
|
||||
using (MySqlConnection connection = GetConnection()) {
|
||||
await connection.OpenAsync();
|
||||
|
||||
string command = @"
|
||||
INSERT INTO JobListing
|
||||
@@ -234,7 +300,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
public async Task DeleteJobListing( int JobListingID ) {
|
||||
using (MySqlConnection connection = GetConnection()) {
|
||||
MySqlCommand cmd;
|
||||
connection.Open();
|
||||
await connection.OpenAsync();
|
||||
|
||||
string command = @"
|
||||
UPDATE JobListing
|
||||
|
||||
Reference in New Issue
Block a user