Stream custom live channels using your own media
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
1.1 KiB

using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Repositories;
using LanguageExt;
namespace ErsatzTV.Application.Configuration;
public class GetPaginationSettingsHandler : IRequestHandler<GetPaginationSettings, PaginationSettingsViewModel>
{
private readonly IConfigElementRepository _configElementRepository;
public GetPaginationSettingsHandler(IConfigElementRepository configElementRepository) =>
_configElementRepository = configElementRepository;
public async Task<PaginationSettingsViewModel> Handle(
GetPaginationSettings request,
CancellationToken cancellationToken)
{
Option<ConfigElement> maybeElement = await _configElementRepository.GetConfigElement(
ConfigElementKey.PagesDefaultPageSize,
cancellationToken);
int defaultPageSize = PaginationOptions.NormalizePageSize(
maybeElement.Bind<int?>(element => int.TryParse(element.Value, out int value) ? value : null));
return new PaginationSettingsViewModel { DefaultPageSize = defaultPageSize };
}
}