creazione primi repository e interfacce
This commit is contained in:
1 parent
b7983dae8e
commit
0a6744e8b0
19 files changed
+644
-39
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MySqlConnector;
|
||||
using uWine.Core.Domain.Entities;
|
||||
using uWine.Core.Domain.Repositories;
|
||||
|
||||
@@ -15,8 +16,7 @@ namespace uWine.Core.Infrastructure.Repository
|
||||
using (var connection = Connection())
|
||||
{
|
||||
connection.Open();
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = $@"INSERT INTO t_addresses (
|
||||
var query = $@"INSERT INTO t_addresses (
|
||||
country,
|
||||
postal_code,
|
||||
county,
|
||||
@@ -39,6 +39,8 @@ namespace uWine.Core.Infrastructure.Repository
|
||||
@longitude,
|
||||
@active
|
||||
)";
|
||||
using var command = new MySqlCommand(query, connection); //connection.CreateCommand();
|
||||
|
||||
command.Parameters.AddWithValue("@country", address.Country);
|
||||
command.Parameters.AddWithValue("@postal_code", address.PostalCode);
|
||||
command.Parameters.AddWithValue("@county", address.County);
|
||||
@@ -58,11 +60,12 @@ namespace uWine.Core.Infrastructure.Repository
|
||||
var addresses = new List<Address>();
|
||||
using (var connection = Connection())
|
||||
{
|
||||
connection.Open();
|
||||
var command = connection.CreateCommand();
|
||||
command.CommandText = $@"SELECT a.* FROM t_addresses a
|
||||
connection.Open();
|
||||
var query = $@"SELECT a.* FROM t_addresses a
|
||||
JOIN t_owners_addresses oa ON a.id = oa.address_id
|
||||
WHERE oa.owner_id = @OwnerId";
|
||||
|
||||
using var command = new MySqlCommand(query, connection);
|
||||
command.Parameters.AddWithValue("@OwnerId", OwnerId);
|
||||
using (var reader = command.ExecuteReader())
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user