Thread on the server better

This commit is contained in:
2025-08-04 16:27:41 -07:00
parent 109306dda2
commit 35018d921b
4 changed files with 85 additions and 25 deletions
@@ -10,7 +10,7 @@ namespace BoredCareers.Services.DatabaseService {
public async Task<Employee?> GetEmployee( int EmployeeID ) {
Employee? employee = null;
using( MySqlConnection connection = GetConnection() ) {
connection.Open();
await connection.OpenAsync();
string command = @"
SELECT *
FROM Employee
@@ -23,7 +23,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 _accountid = reader.GetInt32("AccountID");
int _companyid = reader.GetInt32("CompanyID");
@@ -66,7 +65,7 @@ namespace BoredCareers.Services.DatabaseService {
public async Task<Employee[]> GetEmployeesFromCompany(int CompanyID) {
List<Employee> employees = new List<Employee>();
using (MySqlConnection connection = GetConnection()) {
connection.Open();
await connection.OpenAsync();
string command = @"
SELECT *
FROM Employee
@@ -79,7 +78,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 _accountid = reader.GetInt32("AccountID");
int _companyid = reader.GetInt32("CompanyID");
@@ -122,7 +120,7 @@ namespace BoredCareers.Services.DatabaseService {
public async Task<Employee[]> GetEmployeesFromAccount(int AccountID) {
List<Employee> employees = new List<Employee>();
using (MySqlConnection connection = GetConnection()) {
connection.Open();
await connection.OpenAsync();
string command = @"
SELECT *
FROM Employee
@@ -135,7 +133,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 _accountid = reader.GetInt32("AccountID");
int _companyid = reader.GetInt32("CompanyID");
@@ -177,7 +174,7 @@ namespace BoredCareers.Services.DatabaseService {
public async Task SetEmployee(Employee employee) {
using (MySqlConnection connection = GetConnection()) {
connection.Open();
await connection.OpenAsync();
string command = @"
INSERT INTO Employee
@@ -201,7 +198,7 @@ namespace BoredCareers.Services.DatabaseService {
public async Task DeleteEmployee( int EmployeeID ) {
using( MySqlConnection connection = GetConnection() ) {
MySqlCommand cmd;
connection.Open();
await connection.OpenAsync();
string command = @"
DELETE FROM Employee WHERE ID = @ID;