Thread on the server better
This commit is contained in:
@@ -10,7 +10,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task<Company?> GetCompany( int CompanyID ) {
|
public async Task<Company?> GetCompany( int CompanyID ) {
|
||||||
Company? company = null;
|
Company? company = null;
|
||||||
using( MySqlConnection connection = GetConnection() ) {
|
using( MySqlConnection connection = GetConnection() ) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
string command = @"
|
string command = @"
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM Company
|
FROM Company
|
||||||
@@ -22,7 +22,6 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
using( DbDataReader reader = await cmd.ExecuteReaderAsync() ) {
|
using( DbDataReader reader = await cmd.ExecuteReaderAsync() ) {
|
||||||
while( await reader.ReadAsync() ) {
|
while( await reader.ReadAsync() ) {
|
||||||
if( reader == null ) { break; }
|
|
||||||
int _id = reader.GetInt32("ID");
|
int _id = reader.GetInt32("ID");
|
||||||
string _name = reader.GetString("Name");
|
string _name = reader.GetString("Name");
|
||||||
string _email = reader.GetString("Email");
|
string _email = reader.GetString("Email");
|
||||||
@@ -58,8 +57,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
public async Task<int> SetCompany( Company company ) {
|
public async Task<int> SetCompany( Company company ) {
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
using (MySqlConnection connection = GetConnection()) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
|
|
||||||
string command = @"
|
string command = @"
|
||||||
INSERT INTO Company
|
INSERT INTO Company
|
||||||
(ID,Name,Email,EmailVerified,WebsiteURL,Logo,Phone,PostalCode,Country,StateOrRegion,City,Description)
|
(ID,Name,Email,EmailVerified,WebsiteURL,Logo,Phone,PostalCode,Country,StateOrRegion,City,Description)
|
||||||
@@ -104,7 +102,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task DeleteCompany( int CompanyID ) {
|
public async Task DeleteCompany( int CompanyID ) {
|
||||||
using( MySqlConnection connection = GetConnection() ) {
|
using( MySqlConnection connection = GetConnection() ) {
|
||||||
MySqlCommand cmd;
|
MySqlCommand cmd;
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
|
|
||||||
string command = @"
|
string command = @"
|
||||||
DELETE FROM Company WHERE ID = @ID;
|
DELETE FROM Company WHERE ID = @ID;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task<Employee?> GetEmployee( int EmployeeID ) {
|
public async Task<Employee?> GetEmployee( int EmployeeID ) {
|
||||||
Employee? employee = null;
|
Employee? employee = null;
|
||||||
using( MySqlConnection connection = GetConnection() ) {
|
using( MySqlConnection connection = GetConnection() ) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
string command = @"
|
string command = @"
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM Employee
|
FROM Employee
|
||||||
@@ -23,7 +23,6 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
using( DbDataReader reader = await cmd.ExecuteReaderAsync() ) {
|
using( DbDataReader reader = await cmd.ExecuteReaderAsync() ) {
|
||||||
while( await reader.ReadAsync() ) {
|
while( await reader.ReadAsync() ) {
|
||||||
if( reader == null ) { break; }
|
|
||||||
int _id = reader.GetInt32("ID");
|
int _id = reader.GetInt32("ID");
|
||||||
int _accountid = reader.GetInt32("AccountID");
|
int _accountid = reader.GetInt32("AccountID");
|
||||||
int _companyid = reader.GetInt32("CompanyID");
|
int _companyid = reader.GetInt32("CompanyID");
|
||||||
@@ -66,7 +65,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task<Employee[]> GetEmployeesFromCompany(int CompanyID) {
|
public async Task<Employee[]> GetEmployeesFromCompany(int CompanyID) {
|
||||||
List<Employee> employees = new List<Employee>();
|
List<Employee> employees = new List<Employee>();
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
using (MySqlConnection connection = GetConnection()) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
string command = @"
|
string command = @"
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM Employee
|
FROM Employee
|
||||||
@@ -79,7 +78,6 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
||||||
while (await reader.ReadAsync()) {
|
while (await reader.ReadAsync()) {
|
||||||
if (reader == null) { break; }
|
|
||||||
int _id = reader.GetInt32("ID");
|
int _id = reader.GetInt32("ID");
|
||||||
int _accountid = reader.GetInt32("AccountID");
|
int _accountid = reader.GetInt32("AccountID");
|
||||||
int _companyid = reader.GetInt32("CompanyID");
|
int _companyid = reader.GetInt32("CompanyID");
|
||||||
@@ -122,7 +120,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task<Employee[]> GetEmployeesFromAccount(int AccountID) {
|
public async Task<Employee[]> GetEmployeesFromAccount(int AccountID) {
|
||||||
List<Employee> employees = new List<Employee>();
|
List<Employee> employees = new List<Employee>();
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
using (MySqlConnection connection = GetConnection()) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
string command = @"
|
string command = @"
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM Employee
|
FROM Employee
|
||||||
@@ -135,7 +133,6 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
||||||
while (await reader.ReadAsync()) {
|
while (await reader.ReadAsync()) {
|
||||||
if (reader == null) { break; }
|
|
||||||
int _id = reader.GetInt32("ID");
|
int _id = reader.GetInt32("ID");
|
||||||
int _accountid = reader.GetInt32("AccountID");
|
int _accountid = reader.GetInt32("AccountID");
|
||||||
int _companyid = reader.GetInt32("CompanyID");
|
int _companyid = reader.GetInt32("CompanyID");
|
||||||
@@ -177,7 +174,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
public async Task SetEmployee(Employee employee) {
|
public async Task SetEmployee(Employee employee) {
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
using (MySqlConnection connection = GetConnection()) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
|
|
||||||
string command = @"
|
string command = @"
|
||||||
INSERT INTO Employee
|
INSERT INTO Employee
|
||||||
@@ -201,7 +198,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task DeleteEmployee( int EmployeeID ) {
|
public async Task DeleteEmployee( int EmployeeID ) {
|
||||||
using( MySqlConnection connection = GetConnection() ) {
|
using( MySqlConnection connection = GetConnection() ) {
|
||||||
MySqlCommand cmd;
|
MySqlCommand cmd;
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
|
|
||||||
string command = @"
|
string command = @"
|
||||||
DELETE FROM Employee WHERE ID = @ID;
|
DELETE FROM Employee WHERE ID = @ID;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task<JobListing[]> GetJobListingPage(int PageNumber, int CountPerPage) {
|
public async Task<JobListing[]> GetJobListingPage(int PageNumber, int CountPerPage) {
|
||||||
List<JobListing> joblistings = new List<JobListing>();
|
List<JobListing> joblistings = new List<JobListing>();
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
using (MySqlConnection connection = GetConnection()) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
string command = @"
|
string command = @"
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM JobListing
|
FROM JobListing
|
||||||
@@ -24,7 +24,6 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
||||||
while (await reader.ReadAsync()) {
|
while (await reader.ReadAsync()) {
|
||||||
if (reader == null) { break; }
|
|
||||||
int _id = reader.GetInt32("ID");
|
int _id = reader.GetInt32("ID");
|
||||||
int _companyid = reader.GetInt32("CompanyID");
|
int _companyid = reader.GetInt32("CompanyID");
|
||||||
string _title = reader.GetString("Title");
|
string _title = reader.GetString("Title");
|
||||||
@@ -69,7 +68,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task<JobListing[]> GetJobListingFromCompany(int CompanyID) {
|
public async Task<JobListing[]> GetJobListingFromCompany(int CompanyID) {
|
||||||
List<JobListing> joblistings = new List<JobListing>(); ;
|
List<JobListing> joblistings = new List<JobListing>(); ;
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
using (MySqlConnection connection = GetConnection()) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
string command = @"
|
string command = @"
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM JobListing
|
FROM JobListing
|
||||||
@@ -81,7 +80,6 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
||||||
while (await reader.ReadAsync()) {
|
while (await reader.ReadAsync()) {
|
||||||
if (reader == null) { break; }
|
|
||||||
int _id = reader.GetInt32("ID");
|
int _id = reader.GetInt32("ID");
|
||||||
int _companyid = reader.GetInt32("CompanyID");
|
int _companyid = reader.GetInt32("CompanyID");
|
||||||
string _title = reader.GetString("Title");
|
string _title = reader.GetString("Title");
|
||||||
@@ -126,7 +124,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task<JobListing?> GetJobListing(int JobListingID) {
|
public async Task<JobListing?> GetJobListing(int JobListingID) {
|
||||||
JobListing? joblisting = null;
|
JobListing? joblisting = null;
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
using (MySqlConnection connection = GetConnection()) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
string command = @"
|
string command = @"
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM JobListing
|
FROM JobListing
|
||||||
@@ -138,7 +136,6 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
using (DbDataReader reader = await cmd.ExecuteReaderAsync()) {
|
||||||
while (await reader.ReadAsync()) {
|
while (await reader.ReadAsync()) {
|
||||||
if (reader == null) { break; }
|
|
||||||
int _id = reader.GetInt32("ID");
|
int _id = reader.GetInt32("ID");
|
||||||
int _companyid = reader.GetInt32("CompanyID");
|
int _companyid = reader.GetInt32("CompanyID");
|
||||||
string _title = reader.GetString("Title");
|
string _title = reader.GetString("Title");
|
||||||
@@ -180,9 +177,78 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
return joblisting;
|
return joblisting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SetJobListing( JobListing jobListing ) {
|
public async Task<JobListing[]> GetJobListingsPastExipre() {
|
||||||
|
List<JobListing> joblistings = new List<JobListing>();
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
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 = @"
|
string command = @"
|
||||||
INSERT INTO JobListing
|
INSERT INTO JobListing
|
||||||
@@ -234,7 +300,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task DeleteJobListing( int JobListingID ) {
|
public async Task DeleteJobListing( int JobListingID ) {
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
using (MySqlConnection connection = GetConnection()) {
|
||||||
MySqlCommand cmd;
|
MySqlCommand cmd;
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
|
|
||||||
string command = @"
|
string command = @"
|
||||||
UPDATE JobListing
|
UPDATE JobListing
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
public async Task<JobListingSkill[]> GetJobListingSkills(int JobListingID) {
|
public async Task<JobListingSkill[]> GetJobListingSkills(int JobListingID) {
|
||||||
List<JobListingSkill> joblistingskills = new List<JobListingSkill>();
|
List<JobListingSkill> joblistingskills = new List<JobListingSkill>();
|
||||||
using (MySqlConnection connection = GetConnection()) {
|
using (MySqlConnection connection = GetConnection()) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
string command = @"
|
string command = @"
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM JobListingSkill
|
FROM JobListingSkill
|
||||||
@@ -41,8 +41,7 @@ namespace BoredCareers.Services.DatabaseService {
|
|||||||
|
|
||||||
public async Task SetJobListingSkills( JobListingSkill jobListingSkill ) {
|
public async Task SetJobListingSkills( JobListingSkill jobListingSkill ) {
|
||||||
using( MySqlConnection connection = GetConnection() ) {
|
using( MySqlConnection connection = GetConnection() ) {
|
||||||
connection.Open();
|
await connection.OpenAsync();
|
||||||
|
|
||||||
string command = @"
|
string command = @"
|
||||||
INSERT INTO JobListing
|
INSERT INTO JobListing
|
||||||
(ID,JobListingID,Name,Description)
|
(ID,JobListingID,Name,Description)
|
||||||
|
|||||||
Reference in New Issue
Block a user