[CHANGE] Working on client manager

This commit is contained in:
max
2025-08-31 21:36:53 +02:00
parent 2f018d131e
commit 0ab0a029c4
2 changed files with 41 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ using DotBased.Monads;
using Manager.App.Models.Library;
using Manager.App.Models.Settings;
using Manager.Data.Contexts;
using Manager.Data.Entities.LibraryContext;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
@@ -45,13 +46,21 @@ public class LibraryService : ILibraryService
}
catch (Exception e)
{
if (e is OperationCanceledException)
{
return ResultError.Fail("Library service operation cancelled");
return HandleException(e);
}
}
_logger.LogError(e, "Failed to get library information");
return ResultError.Fail("Failed to get library information");
public async Task<Result<List<ClientAccountEntity>>> GetAccountsAsync(int total = 20, int offset = 0, CancellationToken cancellationToken = default)
{
try
{
await using var context = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
var orderedAccounts = context.Accounts.OrderBy(x => x.Id).Skip(offset).Take(total);
return orderedAccounts.ToList();
}
catch (Exception e)
{
return HandleException(e);
}
}
@@ -68,4 +77,15 @@ public class LibraryService : ILibraryService
throw;
}
}
private ResultError HandleException(Exception exception)
{
if (exception is OperationCanceledException)
{
return ResultError.Fail("Library service operation cancelled");
}
_logger.LogError(exception, "Failed to get library information");
return ResultError.Fail("Failed to get library information");
}
}

View File

@@ -0,0 +1,15 @@
using Manager.YouTube;
namespace Manager.App.Services.System;
public class ClientManager : BackgroundService
{
private readonly List<YouTubeClient> _clients = [];
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
throw new NotImplementedException();
}
}