// // Copyright (c) alveus.dev. All rights reserved. Licensed under the MIT License. // using Astral.Core.Entities; using Astral.Core.Infrastructure; using Astral.Core.RepositoryInterfaces; using Dapper; using Injectio.Attributes; namespace Astral.DAL.Repositories; /// [RegisterScoped] public class UserRepository : BaseRepository, IUserRepository { /// /// Initializes a new instance of the class. /// /// Instance of . public UserRepository(IDbConnectionProvider db) : base(db) { } /// public async Task CountUsersAsync() { return await WithDatabaseAsync(async connection => await connection.QueryFirstAsync($"SELECT COUNT(*) FROM {Table};")); } /// public async Task FindByUsername(string username) { return await WithDatabaseAsync(async connection => await connection.QueryFirstOrDefaultAsync($"SELECT * FROM {Table} WHERE username = @pUsername", new { pUsername = username })); } /// public async Task FindByEmailAddress(string emailAddress) { return await WithDatabaseAsync(async connection => await connection.QueryFirstOrDefaultAsync($"SELECT * FROM {Table} WHERE email = @pEmailAddress", new { pEmailAddress = emailAddress })); } }