From 0ab0a029c4ec8c8cd4c162a2c45a7d4a2141b138 Mon Sep 17 00:00:00 2001 From: max Date: Sun, 31 Aug 2025 21:36:53 +0200 Subject: [PATCH] [CHANGE] Working on client manager --- Manager.App/Services/LibraryService.cs | 32 ++++++++++++++++---- Manager.App/Services/System/ClientManager.cs | 15 +++++++++ 2 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 Manager.App/Services/System/ClientManager.cs diff --git a/Manager.App/Services/LibraryService.cs b/Manager.App/Services/LibraryService.cs index 52b4d4f..f93fca0 100644 --- a/Manager.App/Services/LibraryService.cs +++ b/Manager.App/Services/LibraryService.cs @@ -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>> 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"); + } } \ No newline at end of file diff --git a/Manager.App/Services/System/ClientManager.cs b/Manager.App/Services/System/ClientManager.cs new file mode 100644 index 0000000..178aab4 --- /dev/null +++ b/Manager.App/Services/System/ClientManager.cs @@ -0,0 +1,15 @@ +using Manager.YouTube; + +namespace Manager.App.Services.System; + +public class ClientManager : BackgroundService +{ + private readonly List _clients = []; + + protected override Task ExecuteAsync(CancellationToken stoppingToken) + { + throw new NotImplementedException(); + } + + +} \ No newline at end of file