Fix time for the job listing record

This commit is contained in:
2025-08-04 16:49:37 -07:00
parent d167405ef1
commit 2d627733d7
@@ -232,20 +232,6 @@ namespace BoredCareers.Services.DatabaseService {
return joblistings.ToArray(); 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) { public async Task SetJobListing(JobListing jobListing) {
using (MySqlConnection connection = GetConnection()) { using (MySqlConnection connection = GetConnection()) {
await connection.OpenAsync(); await connection.OpenAsync();
@@ -267,7 +253,6 @@ namespace BoredCareers.Services.DatabaseService {
JobType = @JobType, JobType = @JobType,
Remote = @Remote, Remote = @Remote,
Description = @Description, Description = @Description,
CreatedTime = @CreatedTime,
ModifiedTime = @ModifiedTime, ModifiedTime = @ModifiedTime,
IsDeleted = @IsDeleted; IsDeleted = @IsDeleted;
"; ";
@@ -285,8 +270,8 @@ namespace BoredCareers.Services.DatabaseService {
cmd.Parameters.AddWithValue("@JobType", jobListing.JobType); cmd.Parameters.AddWithValue("@JobType", jobListing.JobType);
cmd.Parameters.AddWithValue("@Remote", jobListing.Remote); cmd.Parameters.AddWithValue("@Remote", jobListing.Remote);
cmd.Parameters.AddWithValue("@Description", jobListing.Description); cmd.Parameters.AddWithValue("@Description", jobListing.Description);
cmd.Parameters.AddWithValue("@CreatedTime", jobListing.CreatedTime.ToUniversalTime()); cmd.Parameters.AddWithValue("@CreatedTime", DateTime.UtcNow);
cmd.Parameters.AddWithValue("@ModifiedTime", jobListing.ModifiedTime.ToUniversalTime()); cmd.Parameters.AddWithValue("@ModifiedTime", DateTime.UtcNow);
cmd.Parameters.AddWithValue("@IsDeleted", jobListing.IsDeleted); cmd.Parameters.AddWithValue("@IsDeleted", jobListing.IsDeleted);
await cmd.ExecuteNonQueryAsync(); await cmd.ExecuteNonQueryAsync();
@@ -297,7 +282,21 @@ namespace BoredCareers.Services.DatabaseService {
} }
} }
public async Task DeleteJobListing( int JobListingID ) { 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 DeleteJobListing(int JobListingID) {
using (MySqlConnection connection = GetConnection()) { using (MySqlConnection connection = GetConnection()) {
MySqlCommand cmd; MySqlCommand cmd;
await connection.OpenAsync(); await connection.OpenAsync();