mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-16 17:47:22 +00:00
Format ./web/backend/Features/Features.UserManagement
This commit is contained in:
@@ -42,10 +42,7 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
||||
/// <param name="offset">The number of records to skip, or <c>null</c> for no offset.</param>
|
||||
/// <returns>The collection of matching <see cref="Domain.Entities.UserAccount" /> records.</returns>
|
||||
/// <exception cref="Microsoft.Data.SqlClient.SqlException">Thrown when the database command fails.</exception>
|
||||
public async Task<IEnumerable<UserAccount>> GetAllAsync(
|
||||
int? limit,
|
||||
int? offset
|
||||
)
|
||||
public async Task<IEnumerable<UserAccount>> GetAllAsync(int? limit, int? offset)
|
||||
{
|
||||
await using DbConnection connection = await CreateConnection();
|
||||
await using DbCommand command = connection.CreateCommand();
|
||||
@@ -61,7 +58,8 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
||||
await using DbDataReader reader = await command.ExecuteReaderAsync();
|
||||
List<UserAccount> users = new();
|
||||
|
||||
while (await reader.ReadAsync()) users.Add(MapToEntity(reader));
|
||||
while (await reader.ReadAsync())
|
||||
users.Add(MapToEntity(reader));
|
||||
|
||||
return users;
|
||||
}
|
||||
@@ -111,9 +109,7 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
||||
/// <param name="username">The username to search for.</param>
|
||||
/// <returns>The matching <see cref="Domain.Entities.UserAccount" />, or <c>null</c> if not found.</returns>
|
||||
/// <exception cref="Microsoft.Data.SqlClient.SqlException">Thrown when the database command fails.</exception>
|
||||
public async Task<UserAccount?> GetByUsernameAsync(
|
||||
string username
|
||||
)
|
||||
public async Task<UserAccount?> GetByUsernameAsync(string username)
|
||||
{
|
||||
await using DbConnection connection = await CreateConnection();
|
||||
await using DbCommand command = connection.CreateCommand();
|
||||
@@ -132,9 +128,7 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
||||
/// <param name="email">The email address to search for.</param>
|
||||
/// <returns>The matching <see cref="Domain.Entities.UserAccount" />, or <c>null</c> if not found.</returns>
|
||||
/// <exception cref="Microsoft.Data.SqlClient.SqlException">Thrown when the database command fails.</exception>
|
||||
public async Task<UserAccount?> GetByEmailAsync(
|
||||
string email
|
||||
)
|
||||
public async Task<UserAccount?> GetByEmailAsync(string email)
|
||||
{
|
||||
await using DbConnection connection = await CreateConnection();
|
||||
await using DbCommand command = connection.CreateCommand();
|
||||
@@ -152,9 +146,7 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
||||
/// </summary>
|
||||
/// <param name="reader">The data reader positioned on the row to map.</param>
|
||||
/// <returns>The mapped <see cref="Domain.Entities.UserAccount" /> instance.</returns>
|
||||
protected override UserAccount MapToEntity(
|
||||
DbDataReader reader
|
||||
)
|
||||
protected override UserAccount MapToEntity(DbDataReader reader)
|
||||
{
|
||||
return new UserAccount
|
||||
{
|
||||
@@ -168,9 +160,7 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
||||
? null
|
||||
: reader.GetDateTime(reader.GetOrdinal("UpdatedAt")),
|
||||
DateOfBirth = reader.GetDateTime(reader.GetOrdinal("DateOfBirth")),
|
||||
Timer = reader.IsDBNull(reader.GetOrdinal("Timer"))
|
||||
? null
|
||||
: (byte[])reader["Timer"]
|
||||
Timer = reader.IsDBNull(reader.GetOrdinal("Timer")) ? null : (byte[])reader["Timer"],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -181,15 +171,11 @@ public class UserAccountRepository(ISqlConnectionFactory connectionFactory)
|
||||
/// <param name="command">The command to add the parameter to.</param>
|
||||
/// <param name="name">The parameter name (including any prefix, e.g. "@Username").</param>
|
||||
/// <param name="value">The parameter value, or <c>null</c> to bind <see cref="DBNull.Value" />.</param>
|
||||
private static void AddParameter(
|
||||
DbCommand command,
|
||||
string name,
|
||||
object? value
|
||||
)
|
||||
private static void AddParameter(DbCommand command, string name, object? value)
|
||||
{
|
||||
DbParameter p = command.CreateParameter();
|
||||
p.ParameterName = name;
|
||||
p.Value = value ?? DBNull.Value;
|
||||
command.Parameters.Add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user