[CHANGE] Adding accounts

This commit is contained in:
max
2025-09-04 10:37:38 +02:00
parent f7bfee5de2
commit a8cfbbe0db
7 changed files with 145 additions and 5 deletions

View File

@@ -1,9 +1,13 @@
using DotBased.Monads;
using Manager.App.Models.Library;
using Manager.App.Models.System;
using Manager.Data.Entities.LibraryContext;
namespace Manager.App.Services;
public interface ILibraryService
{
public Task<Result<LibraryInformation>> GetLibraryInfoAsync(CancellationToken cancellationToken = default);
public Task<ListResult<ChannelEntity>> GetChannelAccountsAsync(int total = 20, int offset = 0, CancellationToken cancellationToken = default);
}

View File

@@ -1,6 +1,7 @@
using DotBased.Monads;
using Manager.App.Models.Library;
using Manager.App.Models.Settings;
using Manager.App.Models.System;
using Manager.Data.Contexts;
using Manager.Data.Entities.LibraryContext;
using Microsoft.EntityFrameworkCore;
@@ -50,13 +51,13 @@ public class LibraryService : ILibraryService
}
}
public async Task<Result<List<ChannelEntity>>> GetAccountsAsync(int total = 20, int offset = 0, CancellationToken cancellationToken = default)
public async Task<ListResult<ChannelEntity>> GetChannelAccountsAsync(int total = 20, int offset = 0, CancellationToken cancellationToken = default)
{
try
{
await using var context = await _dbContextFactory.CreateDbContextAsync(cancellationToken);
var orderedAccounts = context.Channels.Include(x => x.ClientAccount).Where(x => x.ClientAccount != null).OrderBy(x => x.Id).Skip(offset).Take(total);
return orderedAccounts.ToList();
var orderedAccounts = context.Channels.Include(x => x.ClientAccount).Where(x => x.ClientAccount != null).OrderBy(x => x.Id);
return new ListResultReturn<ChannelEntity>(orderedAccounts.Skip(offset).Take(total).ToList(), orderedAccounts.Count());
}
catch (Exception e)
{