mirror of https://github.com/ErsatzTV/ErsatzTV.git
9 changed files with 81 additions and 16 deletions
@ -0,0 +1,3 @@ |
|||||||
|
namespace ErsatzTV.Application.Channels; |
||||||
|
|
||||||
|
public record GetChannelResolution(string ChannelNumber) : IRequest<Option<ResolutionViewModel>>; |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
using ErsatzTV.Core.Domain; |
||||||
|
using ErsatzTV.Infrastructure.Data; |
||||||
|
using ErsatzTV.Infrastructure.Extensions; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
|
||||||
|
namespace ErsatzTV.Application.Channels; |
||||||
|
|
||||||
|
public class GetChannelResolutionHandler(IDbContextFactory<TvContext> dbContextFactory) |
||||||
|
: IRequestHandler<GetChannelResolution, Option<ResolutionViewModel>> |
||||||
|
{ |
||||||
|
public async Task<Option<ResolutionViewModel>> Handle( |
||||||
|
GetChannelResolution request, |
||||||
|
CancellationToken cancellationToken) |
||||||
|
{ |
||||||
|
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); |
||||||
|
|
||||||
|
Option<Channel> maybeChannel = await dbContext.Channels |
||||||
|
.AsNoTracking() |
||||||
|
.Include(c => c.FFmpegProfile) |
||||||
|
.ThenInclude(ff => ff.Resolution) |
||||||
|
.SelectOneAsync(c => c.Number, c => c.Number == request.ChannelNumber); |
||||||
|
|
||||||
|
return maybeChannel.Map(c => Mapper.ProjectToViewModel(c.FFmpegProfile.Resolution)); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,3 @@ |
|||||||
|
namespace ErsatzTV.Application.Channels; |
||||||
|
|
||||||
|
public record ResolutionViewModel(int Height, int Width); |
||||||
Loading…
Reference in new issue