UI #5
@@ -55,7 +55,7 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
return company;
|
||||
}
|
||||
|
||||
public async Task SetCompany( Company company ) {
|
||||
public async Task<int> SetCompany( Company company ) {
|
||||
using (MySqlConnection connection = GetConnection()) {
|
||||
connection.Open();
|
||||
|
||||
@@ -76,6 +76,8 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
StateOrRegion = @StateOrRegion,
|
||||
City = @City,
|
||||
Description = @Description;
|
||||
|
||||
Select LAST_INSERT_ID();
|
||||
";
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand(command, connection);
|
||||
@@ -92,7 +94,9 @@ namespace BoredCareers.Services.DatabaseService {
|
||||
cmd.Parameters.AddWithValue("@City", company.City);
|
||||
cmd.Parameters.AddWithValue("@Description", company.Description);
|
||||
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
object? result = await cmd.ExecuteScalarAsync();
|
||||
int insertedId = result != null ? Convert.ToInt32(result) : 0;
|
||||
return insertedId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user