working #24
@@ -146,6 +146,8 @@ CREATE TABLE IF NOT EXISTS `Company` (
|
||||
CREATE TABLE IF NOT EXISTS `Employee` (
|
||||
`ID` int NOT NULL AUTO_INCREMENT,
|
||||
`AccountID` int NOT NULL,
|
||||
`AccountName` varchar(60) NOT NULL,
|
||||
`AccountEmail` varchar(255) NOT NULL,
|
||||
`CompanyID` int NOT NULL,
|
||||
PRIMARY KEY (`ID`),
|
||||
FOREIGN KEY (`CompanyID`) REFERENCES `Company`(`ID`) ON DELETE CASCADE
|
||||
|
||||
@@ -14,9 +14,3 @@ export class Company {
|
||||
public city: string = "";
|
||||
public description: string = "";
|
||||
}
|
||||
|
||||
export class Employee {
|
||||
public id: number | null = null;
|
||||
public accountID: number = 0;
|
||||
public company: Company = new Company;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Company } from "./Company";
|
||||
|
||||
export class Employee {
|
||||
public id: number | null = null;
|
||||
public accountID: number = 0;
|
||||
public accountName: string = "";
|
||||
public accountEmail: string = "";
|
||||
public company: Company = new Company;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
namespace BoredCareers.Entities {
|
||||
|
||||
public class Company {
|
||||
public int? ID { get; set; } // PK
|
||||
public string Name { get; set; } = "";
|
||||
@@ -17,11 +16,4 @@ namespace BoredCareers.Entities {
|
||||
public string City { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
}
|
||||
|
||||
public class Employee {
|
||||
public int? ID { get; set; } // PK
|
||||
public int AccountID { get; set; } // FK
|
||||
public Company Company { get; set; } = new Company(); // FK
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace BoredCareers.Entities {
|
||||
public class Employee {
|
||||
public int? ID { get; set; } // PK
|
||||
public int AccountID { get; set; }
|
||||
public string AccountName { get; set; } = "";
|
||||
public string AccountEmail { get; set; } = "";
|
||||
public Company Company { get; set; } = new Company(); // FK
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
namespace BoredCareers.Entities {
|
||||
|
||||
public class JobListing {
|
||||
public int? ID { get; set; } // PK
|
||||
public int CompanyID { get; set; } // FK
|
||||
@@ -25,5 +24,4 @@ namespace BoredCareers.Entities {
|
||||
public string Name { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
namespace BoredCareers.Entities {
|
||||
|
||||
public class Resume {
|
||||
public int? ID { get; set; } // PK
|
||||
public int AccountID { get; set; } // FK
|
||||
@@ -106,5 +105,4 @@ namespace BoredCareers.Entities {
|
||||
public string URL { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,6 +25,8 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
while( await reader.ReadAsync() ) {
|
||||
int _id = reader.GetInt32("ID");
|
||||
int _accountid = reader.GetInt32("AccountID");
|
||||
string _accountname = reader.GetString("AccountName");
|
||||
string _accountemail = reader.GetString("AccountEmail");
|
||||
int _companyid = reader.GetInt32("CompanyID");
|
||||
string _name = reader.GetString("Name");
|
||||
string _email = reader.GetString("Email");
|
||||
@@ -42,6 +44,8 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
employee = new Employee() {
|
||||
ID = _id,
|
||||
AccountID = _accountid,
|
||||
AccountName = _accountname,
|
||||
AccountEmail = _accountemail,
|
||||
Company = new Company {
|
||||
ID = _companyid,
|
||||
Name = _name,
|
||||
@@ -82,6 +86,8 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
while (await reader.ReadAsync()) {
|
||||
int _id = reader.GetInt32("ID");
|
||||
int _accountid = reader.GetInt32("AccountID");
|
||||
string _accountname = reader.GetString("AccountName");
|
||||
string _accountemail = reader.GetString("AccountEmail");
|
||||
int _companyid = reader.GetInt32("CompanyID");
|
||||
string _name = reader.GetString("Name");
|
||||
string _email = reader.GetString("Email");
|
||||
@@ -99,6 +105,8 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
employees.Add(new Employee() {
|
||||
ID = _id,
|
||||
AccountID = _accountid,
|
||||
AccountName = _accountname,
|
||||
AccountEmail = _accountemail,
|
||||
Company = new Company {
|
||||
ID = _companyid,
|
||||
Name = _name,
|
||||
@@ -139,6 +147,8 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
while (await reader.ReadAsync()) {
|
||||
int _id = reader.GetInt32("ID");
|
||||
int _accountid = reader.GetInt32("AccountID");
|
||||
string _accountname = reader.GetString("AccountName");
|
||||
string _accountemail = reader.GetString("AccountEmail");
|
||||
int _companyid = reader.GetInt32("CompanyID");
|
||||
string _name = reader.GetString("Name");
|
||||
string _email = reader.GetString("Email");
|
||||
@@ -156,6 +166,8 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
employees.Add(new Employee() {
|
||||
ID = _id,
|
||||
AccountID = _accountid,
|
||||
AccountName = _accountname,
|
||||
AccountEmail = _accountemail,
|
||||
Company = new Company {
|
||||
ID = _companyid,
|
||||
Name = _name,
|
||||
@@ -184,9 +196,9 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
|
||||
string command = @"
|
||||
INSERT INTO Employee
|
||||
(ID,AccountID,CompanyID)
|
||||
(ID,AccountID,AccountName,AccountEmail,CompanyID)
|
||||
VALUES
|
||||
(@ID,@AccountID,@CompanyID)
|
||||
(@ID,@AccountID,@AccountName,@AccountEmail,@CompanyID)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
AccountID = @AccountID,
|
||||
CompanyID = @CompanyID;
|
||||
@@ -195,6 +207,8 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
MySqlCommand cmd = new MySqlCommand(command, connection);
|
||||
cmd.Parameters.AddWithValue("@ID", employee.ID);
|
||||
cmd.Parameters.AddWithValue("@AccountID", employee.AccountID);
|
||||
cmd.Parameters.AddWithValue("@AccountName", employee.AccountName);
|
||||
cmd.Parameters.AddWithValue("@AccountEmail", employee.AccountEmail);
|
||||
cmd.Parameters.AddWithValue("@CompanyID", employee.Company.ID);
|
||||
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
|
||||
Reference in New Issue
Block a user