using FreeSql; using F9WebAiTest.Application.Dtos.SYS.Registries; using F9WebAiTest.Application.Interfaces.Repositories.SYS.Registries; using F9WebAiTest.Domain.Entities.SYS.Registries; namespace F9WebAiTest.Infrastructure.FreeSqls.Repositories.SYS.Registries; internal class RegistryReadRepository : F9RepositoryBase, IRegistryReadRepository { public RegistryReadRepository(IFreeSql fsql) : base(fsql) { } public async Task> GetAllAsync() => await Orm.Select() .Where(x => x.DeletedAt == null) .OrderBy(x => x.Category) .OrderBy(x => x.KeyName) .ToListAsync(x => new RegistryReadDto_View(x.Id, x.Category, x.KeyName, x.Value, x.DataType, x.Description, x.IsActive)); public async Task GetByIdForEditAsync(long id) => await Orm.Select() .Where(x => x.Id == id && x.DeletedAt == null) .FirstAsync(x => new RegistryReadDto_Edit(x.Id, x.Category, x.KeyName, x.Value, x.DataType, x.Description, x.IsActive)); public async Task GetByCategoryAndKeyAsync(string category, string keyName) => await Orm.Select() .Where(x => x.DeletedAt == null && x.Category == category && x.KeyName == keyName) .FirstAsync(x => new RegistryReadDto_Edit(x.Id, x.Category, x.KeyName, x.Value, x.DataType, x.Description, x.IsActive)); }