[CHANGE] Preparing library service
This commit is contained in:
34
Manager.App/Services/LibraryService.cs
Normal file
34
Manager.App/Services/LibraryService.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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!");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user