using BakeryErp.Infrastructure.Database; namespace BakeryErp.Infrastructure.Repositories; public sealed class MasterDataLookupRepository { private readonly DatabaseOptions _options; public MasterDataLookupRepository(DatabaseOptions options) { _options = options; } public IReadOnlyList Suppliers() { return LocalDataStoreFile.Load(_options).Suppliers .Where(static supplier => supplier.IsActive) .OrderBy(static supplier => supplier.Code) .Select(static supplier => new LookupOption(supplier.Name, $"{supplier.Code} - {supplier.Name}")) .ToList(); } public IReadOnlyList Items() { return LocalDataStoreFile.Load(_options).Items .Where(static item => item.IsActive) .OrderBy(static item => item.Sku) .Select(static item => new ItemLookupOption(item.Sku, item.Name, item.BaseUnit, $"{item.Sku} - {item.Name}")) .ToList(); } public IReadOnlyList Stores() { return LocalDataStoreFile.Load(_options).Stores .Where(static store => store.IsActive) .OrderBy(static store => store.Code) .Select(static store => new LookupOption(store.Name, $"{store.Code} - {store.Name}")) .ToList(); } public IReadOnlyList Warehouses() { return LocalDataStoreFile.Load(_options).Warehouses .Where(static warehouse => warehouse.IsActive) .OrderBy(static warehouse => warehouse.Code) .Select(static warehouse => new LookupOption(warehouse.Name, $"{warehouse.Code} - {warehouse.Name}")) .ToList(); } } public sealed record LookupOption(string Value, string Label); public sealed record ItemLookupOption(string Sku, string Name, string Unit, string Label);