mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Update namespaces
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
using API.Core.Contracts.Auth;
|
using API.Core.Contracts.Auth;
|
||||||
using API.Core.Contracts.Common;
|
using API.Core.Contracts.Common;
|
||||||
using Domain.Core.Entities;
|
using Domain.Entities;
|
||||||
using Infrastructure.Jwt;
|
using Infrastructure.Jwt;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Service.Core.Auth;
|
using Service.Core.Auth;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Domain.Core.Entities;
|
using Domain.Entities;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Service.Core.User;
|
using Service.Core.User;
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
<Folder Name="/Infrastructure/">
|
<Folder Name="/Infrastructure/">
|
||||||
<Project Path="Infrastructure/Infrastructure.Jwt/Infrastructure.Jwt.csproj" />
|
<Project Path="Infrastructure/Infrastructure.Jwt/Infrastructure.Jwt.csproj" />
|
||||||
<Project Path="Infrastructure/Infrastructure.PasswordHashing/Infrastructure.PasswordHashing.csproj" />
|
<Project Path="Infrastructure/Infrastructure.PasswordHashing/Infrastructure.PasswordHashing.csproj" />
|
||||||
<Project Path="Infrastructure/Infrastructure.Repository.Tests/Repository.Tests.csproj" />
|
|
||||||
<Project Path="Infrastructure/Infrastructure.Repository/Infrastructure.Repository.csproj" />
|
<Project Path="Infrastructure/Infrastructure.Repository/Infrastructure.Repository.csproj" />
|
||||||
|
<Project Path="Infrastructure\Infrastructure.Repository.Tests\Infrastructure.Repository.Tests.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder Name="/Service/">
|
<Folder Name="/Service/">
|
||||||
<Project Path="Service/Service.Core/Service.Core.csproj" />
|
<Project Path="Service/Service.Core/Service.Core.csproj" />
|
||||||
|
|||||||
@@ -2,8 +2,5 @@ using Microsoft.Data.SqlClient;
|
|||||||
|
|
||||||
namespace DBSeed
|
namespace DBSeed
|
||||||
{
|
{
|
||||||
internal interface ISeeder
|
|
||||||
{
|
|
||||||
Task SeedAsync(SqlConnection connection);
|
Task SeedAsync(SqlConnection connection);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using Microsoft.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
|
|
||||||
namespace DBSeed
|
namespace Database.Seed;
|
||||||
{
|
|
||||||
|
|
||||||
internal class LocationSeeder : ISeeder
|
internal class LocationSeeder : ISeeder
|
||||||
{
|
{
|
||||||
private static readonly IReadOnlyList<(
|
private static readonly IReadOnlyList<(
|
||||||
string CountryName,
|
string CountryName,
|
||||||
string CountryCode
|
string CountryCode
|
||||||
@@ -324,5 +323,4 @@ namespace DBSeed
|
|||||||
|
|
||||||
await command.ExecuteNonQueryAsync();
|
await command.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using DBSeed;
|
using Microsoft.Data.SqlClient;
|
||||||
using Microsoft.Data.SqlClient;
|
|
||||||
using DbUp;
|
using DbUp;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Database.Seed;
|
||||||
|
|
||||||
string BuildConnectionString()
|
string BuildConnectionString()
|
||||||
{
|
{
|
||||||
@@ -33,6 +33,7 @@ string BuildConnectionString()
|
|||||||
return builder.ConnectionString;
|
return builder.ConnectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var connectionString = BuildConnectionString();
|
var connectionString = BuildConnectionString();
|
||||||
@@ -72,7 +73,6 @@ try
|
|||||||
|
|
||||||
using (connection)
|
using (connection)
|
||||||
{
|
{
|
||||||
|
|
||||||
ISeeder[] seeders =
|
ISeeder[] seeders =
|
||||||
[
|
[
|
||||||
new LocationSeeder(),
|
new LocationSeeder(),
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Domain.Core.Entities;
|
|
||||||
using idunno.Password;
|
using idunno.Password;
|
||||||
using Konscious.Security.Cryptography;
|
using Konscious.Security.Cryptography;
|
||||||
using Microsoft.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
|
|
||||||
namespace DBSeed
|
namespace Database.Seed;
|
||||||
|
|
||||||
|
internal class UserSeeder : ISeeder
|
||||||
{
|
{
|
||||||
internal class UserSeeder : ISeeder
|
|
||||||
{
|
|
||||||
private static readonly IReadOnlyList<(
|
private static readonly IReadOnlyList<(
|
||||||
string FirstName,
|
string FirstName,
|
||||||
string LastName
|
string LastName
|
||||||
@@ -172,8 +171,6 @@ namespace DBSeed
|
|||||||
createdCredentials++;
|
createdCredentials++;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// add user verification
|
// add user verification
|
||||||
if (await HasUserVerificationAsync(connection, id)) continue;
|
if (await HasUserVerificationAsync(connection, id)) continue;
|
||||||
|
|
||||||
@@ -211,7 +208,6 @@ namespace DBSeed
|
|||||||
|
|
||||||
|
|
||||||
return (Guid)result!;
|
return (Guid)result!;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GeneratePasswordHash(string pwd)
|
private static string GeneratePasswordHash(string pwd)
|
||||||
@@ -268,5 +264,4 @@ namespace DBSeed
|
|||||||
int offsetDays = random.Next(0, 365);
|
int offsetDays = random.Next(0, 365);
|
||||||
return baseDate.AddDays(-offsetDays);
|
return baseDate.AddDays(-offsetDays);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Domain.Core.Entities;
|
namespace Domain.Entities;
|
||||||
|
|
||||||
public class UserAccount
|
public class UserAccount
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Domain.Core.Entities;
|
namespace Domain.Entities;
|
||||||
|
|
||||||
public class UserCredential
|
public class UserCredential
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Domain.Core.Entities;
|
namespace Domain.Entities;
|
||||||
|
|
||||||
public class UserVerification
|
public class UserVerification
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using Domain.Core.Entities;
|
using Domain.Entities;
|
||||||
using Infrastructure.Repository.Sql;
|
using Infrastructure.Repository.Sql;
|
||||||
|
|
||||||
namespace Infrastructure.Repository.Auth;
|
namespace Infrastructure.Repository.Auth;
|
||||||
|
|
||||||
public class AuthRepository
|
public class AuthRepository(ISqlConnectionFactory connectionFactory)
|
||||||
: Repository<Domain.Core.Entities.UserAccount>,
|
: Repository<Domain.Entities.UserAccount>(connectionFactory),
|
||||||
IAuthRepository
|
IAuthRepository
|
||||||
{
|
{
|
||||||
public AuthRepository(ISqlConnectionFactory connectionFactory)
|
public async Task<Domain.Entities.UserAccount> RegisterUserAsync(
|
||||||
: base(connectionFactory) { }
|
|
||||||
|
|
||||||
public async Task<Domain.Core.Entities.UserAccount> RegisterUserAsync(
|
|
||||||
string username,
|
string username,
|
||||||
string firstName,
|
string firstName,
|
||||||
string lastName,
|
string lastName,
|
||||||
@@ -37,7 +34,7 @@ public class AuthRepository
|
|||||||
var result = await command.ExecuteScalarAsync();
|
var result = await command.ExecuteScalarAsync();
|
||||||
var userAccountId = result != null ? (Guid)result : Guid.Empty;
|
var userAccountId = result != null ? (Guid)result : Guid.Empty;
|
||||||
|
|
||||||
return new Domain.Core.Entities.UserAccount
|
return new Domain.Entities.UserAccount
|
||||||
{
|
{
|
||||||
UserAccountId = userAccountId,
|
UserAccountId = userAccountId,
|
||||||
Username = username,
|
Username = username,
|
||||||
@@ -49,7 +46,7 @@ public class AuthRepository
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Domain.Core.Entities.UserAccount?> GetUserByEmailAsync(
|
public async Task<Domain.Entities.UserAccount?> GetUserByEmailAsync(
|
||||||
string email
|
string email
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -64,7 +61,7 @@ public class AuthRepository
|
|||||||
return await reader.ReadAsync() ? MapToEntity(reader) : null;
|
return await reader.ReadAsync() ? MapToEntity(reader) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Domain.Core.Entities.UserAccount?> GetUserByUsernameAsync(
|
public async Task<Domain.Entities.UserAccount?> GetUserByUsernameAsync(
|
||||||
string username
|
string username
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -115,11 +112,11 @@ public class AuthRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maps a data reader row to a UserAccount entity.
|
/// Maps a data reader row to a UserAccount entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override Domain.Core.Entities.UserAccount MapToEntity(
|
protected override Domain.Entities.UserAccount MapToEntity(
|
||||||
DbDataReader reader
|
DbDataReader reader
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return new Domain.Core.Entities.UserAccount
|
return new Domain.Entities.UserAccount
|
||||||
{
|
{
|
||||||
UserAccountId = reader.GetGuid(
|
UserAccountId = reader.GetGuid(
|
||||||
reader.GetOrdinal("UserAccountId")
|
reader.GetOrdinal("UserAccountId")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Domain.Core.Entities;
|
using Domain.Entities;
|
||||||
|
|
||||||
namespace Infrastructure.Repository.Auth;
|
namespace Infrastructure.Repository.Auth;
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ public interface IAuthRepository
|
|||||||
/// <param name="dateOfBirth">User's date of birth</param>
|
/// <param name="dateOfBirth">User's date of birth</param>
|
||||||
/// <param name="passwordHash">Hashed password</param>
|
/// <param name="passwordHash">Hashed password</param>
|
||||||
/// <returns>The newly created UserAccount with generated ID</returns>
|
/// <returns>The newly created UserAccount with generated ID</returns>
|
||||||
Task<Domain.Core.Entities.UserAccount> RegisterUserAsync(
|
Task<Domain.Entities.UserAccount> RegisterUserAsync(
|
||||||
string username,
|
string username,
|
||||||
string firstName,
|
string firstName,
|
||||||
string lastName,
|
string lastName,
|
||||||
@@ -33,7 +33,7 @@ public interface IAuthRepository
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="email">Email address to search for</param>
|
/// <param name="email">Email address to search for</param>
|
||||||
/// <returns>UserAccount if found, null otherwise</returns>
|
/// <returns>UserAccount if found, null otherwise</returns>
|
||||||
Task<Domain.Core.Entities.UserAccount?> GetUserByEmailAsync(
|
Task<Domain.Entities.UserAccount?> GetUserByEmailAsync(
|
||||||
string email
|
string email
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public interface IAuthRepository
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="username">Username to search for</param>
|
/// <param name="username">Username to search for</param>
|
||||||
/// <returns>UserAccount if found, null otherwise</returns>
|
/// <returns>UserAccount if found, null otherwise</returns>
|
||||||
Task<Domain.Core.Entities.UserAccount?> GetUserByUsernameAsync(
|
Task<Domain.Entities.UserAccount?> GetUserByUsernameAsync(
|
||||||
string username
|
string username
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ namespace Infrastructure.Repository.UserAccount;
|
|||||||
|
|
||||||
public interface IUserAccountRepository
|
public interface IUserAccountRepository
|
||||||
{
|
{
|
||||||
Task<Domain.Core.Entities.UserAccount?> GetByIdAsync(Guid id);
|
Task<Domain.Entities.UserAccount?> GetByIdAsync(Guid id);
|
||||||
Task<IEnumerable<Domain.Core.Entities.UserAccount>> GetAllAsync(
|
Task<IEnumerable<Domain.Entities.UserAccount>> GetAllAsync(
|
||||||
int? limit,
|
int? limit,
|
||||||
int? offset
|
int? offset
|
||||||
);
|
);
|
||||||
Task UpdateAsync(Domain.Core.Entities.UserAccount userAccount);
|
Task UpdateAsync(Domain.Entities.UserAccount userAccount);
|
||||||
Task DeleteAsync(Guid id);
|
Task DeleteAsync(Guid id);
|
||||||
Task<Domain.Core.Entities.UserAccount?> GetByUsernameAsync(
|
Task<Domain.Entities.UserAccount?> GetByUsernameAsync(
|
||||||
string username
|
string username
|
||||||
);
|
);
|
||||||
Task<Domain.Core.Entities.UserAccount?> GetByEmailAsync(string email);
|
Task<Domain.Entities.UserAccount?> GetByEmailAsync(string email);
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,10 @@ using Infrastructure.Repository.Sql;
|
|||||||
namespace Infrastructure.Repository.UserAccount;
|
namespace Infrastructure.Repository.UserAccount;
|
||||||
|
|
||||||
public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
||||||
: Repository<Domain.Core.Entities.UserAccount>(connectionFactory),
|
: Repository<Domain.Entities.UserAccount>(connectionFactory),
|
||||||
IUserAccountRepository
|
IUserAccountRepository
|
||||||
{
|
{
|
||||||
public async Task<Domain.Core.Entities.UserAccount?> GetByIdAsync(
|
public async Task<Domain.Entities.UserAccount?> GetByIdAsync(
|
||||||
Guid id
|
Guid id
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -24,7 +24,7 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task<
|
public async Task<
|
||||||
IEnumerable<Domain.Core.Entities.UserAccount>
|
IEnumerable<Domain.Entities.UserAccount>
|
||||||
> GetAllAsync(int? limit, int? offset)
|
> GetAllAsync(int? limit, int? offset)
|
||||||
{
|
{
|
||||||
await using var connection = await CreateConnection();
|
await using var connection = await CreateConnection();
|
||||||
@@ -39,7 +39,7 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
|||||||
AddParameter(command, "@Offset", offset.Value);
|
AddParameter(command, "@Offset", offset.Value);
|
||||||
|
|
||||||
await using var reader = await command.ExecuteReaderAsync();
|
await using var reader = await command.ExecuteReaderAsync();
|
||||||
var users = new List<Domain.Core.Entities.UserAccount>();
|
var users = new List<Domain.Entities.UserAccount>();
|
||||||
|
|
||||||
while (await reader.ReadAsync())
|
while (await reader.ReadAsync())
|
||||||
{
|
{
|
||||||
@@ -50,7 +50,7 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAsync(
|
public async Task UpdateAsync(
|
||||||
Domain.Core.Entities.UserAccount userAccount
|
Domain.Entities.UserAccount userAccount
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
await using var connection = await CreateConnection();
|
await using var connection = await CreateConnection();
|
||||||
@@ -79,7 +79,7 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
|||||||
await command.ExecuteNonQueryAsync();
|
await command.ExecuteNonQueryAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Domain.Core.Entities.UserAccount?> GetByUsernameAsync(
|
public async Task<Domain.Entities.UserAccount?> GetByUsernameAsync(
|
||||||
string username
|
string username
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -94,7 +94,7 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
|||||||
return await reader.ReadAsync() ? MapToEntity(reader) : null;
|
return await reader.ReadAsync() ? MapToEntity(reader) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Domain.Core.Entities.UserAccount?> GetByEmailAsync(
|
public async Task<Domain.Entities.UserAccount?> GetByEmailAsync(
|
||||||
string email
|
string email
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -109,11 +109,11 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
|||||||
return await reader.ReadAsync() ? MapToEntity(reader) : null;
|
return await reader.ReadAsync() ? MapToEntity(reader) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Domain.Core.Entities.UserAccount MapToEntity(
|
protected override Domain.Entities.UserAccount MapToEntity(
|
||||||
DbDataReader reader
|
DbDataReader reader
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return new Domain.Core.Entities.UserAccount
|
return new Domain.Entities.UserAccount
|
||||||
{
|
{
|
||||||
UserAccountId = reader.GetGuid(
|
UserAccountId = reader.GetGuid(
|
||||||
reader.GetOrdinal("UserAccountId")
|
reader.GetOrdinal("UserAccountId")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Domain.Core.Entities;
|
using Domain.Entities;
|
||||||
using Infrastructure.PasswordHashing;
|
using Infrastructure.PasswordHashing;
|
||||||
using Infrastructure.Repository.Auth;
|
using Infrastructure.Repository.Auth;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Domain.Core.Entities;
|
using Domain.Entities;
|
||||||
|
|
||||||
namespace Service.Core.Auth;
|
namespace Service.Core.Auth;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Domain.Core.Entities;
|
using Domain.Entities;
|
||||||
|
|
||||||
namespace Service.Core.User;
|
namespace Service.Core.User;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Domain.Core.Entities;
|
using Domain.Entities;
|
||||||
using Infrastructure.Repository.UserAccount;
|
using Infrastructure.Repository.UserAccount;
|
||||||
|
|
||||||
namespace Service.Core.User;
|
namespace Service.Core.User;
|
||||||
|
|||||||
Reference in New Issue
Block a user