39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using Tiger.Storage;
|
|
|
|
namespace Tiger.Game.Catalogue;
|
|
|
|
public class CatalogueManager : ICatalogueManager
|
|
{
|
|
private readonly IRepository<CataloguePage> _pagesRepository;
|
|
private readonly ILogger<ICatalogueManager> _logger;
|
|
private readonly IRepository<CatalogueFeaturedPage> _featuredPagesRepository;
|
|
|
|
public IDictionary<int, CataloguePage> Pages { get; private set; }
|
|
public IDictionary<int, CatalogueFeaturedPage> FeaturedPages { get; private set; }
|
|
|
|
public CatalogueManager(IRepository<CataloguePage> pagesRepository, ILogger<ICatalogueManager> logger,
|
|
IRepository<CatalogueFeaturedPage> featuredPagesRepository)
|
|
{
|
|
_pagesRepository = pagesRepository;
|
|
_logger = logger;
|
|
_featuredPagesRepository = featuredPagesRepository;
|
|
Pages = new Dictionary<int, CataloguePage>();
|
|
FeaturedPages = new Dictionary<int, CatalogueFeaturedPage>();
|
|
}
|
|
|
|
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);
|
|
}
|
|
} |