26 lines
815 B
C#
26 lines
815 B
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;
|
||
|
|
||
|
public IDictionary<int, CataloguePage> Pages { get; private set; }
|
||
|
|
||
|
public CatalogueManager(IRepository<CataloguePage> pagesRepository, ILogger<ICatalogueManager> logger)
|
||
|
{
|
||
|
_pagesRepository = pagesRepository;
|
||
|
_logger = logger;
|
||
|
Pages = new Dictionary<int, CataloguePage>();
|
||
|
}
|
||
|
|
||
|
public async Task LoadPagesAsync()
|
||
|
{
|
||
|
Pages = (await _pagesRepository.FindByAsync()).ToDictionary(p => p.Id, p => p);
|
||
|
|
||
|
_logger.LogInformation("Loaded {Count} catalogue pages", Pages.Count);
|
||
|
}
|
||
|
}
|