[CHANGE] Working on client manager
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
15
Manager.App/Services/System/ClientManager.cs
Normal file
15
Manager.App/Services/System/ClientManager.cs
Normal 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();
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user