34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
using DotBased.Monads;
|
|
using Manager.App.Models.Library;
|
|
using Manager.App.Models.Settings;
|
|
using Manager.Data.Contexts;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace Manager.App.Services;
|
|
|
|
public class LibraryService : ILibraryService
|
|
{
|
|
private readonly ILogger<LibraryService> _logger;
|
|
private readonly LibrarySettings _librarySettings;
|
|
private readonly IDbContextFactory<LibraryDbContext> _dbContextFactory;
|
|
private readonly DirectoryInfo _libraryDirectory;
|
|
private const string SubDirMedia = "Media";
|
|
private const string SubDirChannels = "Channels";
|
|
|
|
public LibraryService(ILogger<LibraryService> logger, IOptions<LibrarySettings> librarySettings, IDbContextFactory<LibraryDbContext> contextFactory)
|
|
{
|
|
_logger = logger;
|
|
_librarySettings = librarySettings.Value;
|
|
_dbContextFactory = contextFactory;
|
|
_libraryDirectory = Directory.CreateDirectory(Path.Combine(_librarySettings.Path, SubDirMedia));
|
|
_libraryDirectory = Directory.CreateDirectory(Path.Combine(_librarySettings.Path, SubDirChannels));
|
|
}
|
|
|
|
public async Task<Result<LibraryInformation>> GetLibraryInfoAsync()
|
|
{
|
|
await using var context = await _dbContextFactory.CreateDbContextAsync();
|
|
//TODO: Get library info
|
|
return ResultError.Fail("Not implemented!");
|
|
}
|
|
} |