using Microsoft.Extensions.Logging; using Tiger.Storage; namespace Tiger.Game.Catalogue; public class CatalogueManager : ICatalogueManager { private readonly IRepository _pagesRepository; private readonly ILogger _logger; private readonly IRepository _featuredPagesRepository; public IDictionary Pages { get; private set; } public IDictionary FeaturedPages { get; private set; } public CatalogueManager(IRepository pagesRepository, ILogger logger, IRepository featuredPagesRepository) { _pagesRepository = pagesRepository; _logger = logger; _featuredPagesRepository = featuredPagesRepository; Pages = new Dictionary(); FeaturedPages = new Dictionary(); } public async Task LoadPagesAsync() { Pages = (await _pagesRepository.FindByAsync()).ToDictionary(p => p.Id, p => p); _logger.LogInformation("Loaded {Count} catalogue pages", Pages.Count); } public async Task LoadFeaturedPagesAsync() { FeaturedPages =(await _featuredPagesRepository.FindByAsync()) .ToDictionary(p => p.SlotId, p => p); _logger.LogInformation("Loaded {Count} catalogue featured pages", FeaturedPages.Count); } }