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.
 
 
 
 

33 lines
1.2 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);
Option<int> maybePageSize =
maybeElement.Bind(element =>
int.TryParse(element.Value, out int value)
? Prelude.Some(value)
: Option<int>.None);
int defaultPageSize = PaginationOptions.NormalizePageSize(maybePageSize.ToNullable());
return new PaginationSettingsViewModel { DefaultPageSize = defaultPageSize };
}
}