From a38f1bdf3c3128c0071d006f147fd006e36ae4fc Mon Sep 17 00:00:00 2001 From: Jason Dove Date: Sun, 28 Feb 2021 11:12:24 -0600 Subject: [PATCH] fix adding new channel with logo --- .../Channels/Commands/CreateChannelHandler.cs | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs b/ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs index 2d1dac842..229e60e17 100644 --- a/ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs +++ b/ErsatzTV.Application/Channels/Commands/CreateChannelHandler.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using ErsatzTV.Core; @@ -36,10 +37,29 @@ namespace ErsatzTV.Application.Channels.Commands private async Task> Validate(CreateChannel request) => (ValidateName(request), ValidateNumber(request), await FFmpegProfileMustExist(request)) .Apply( - (name, number, ffmpegProfileId) => new Channel(Guid.NewGuid()) + (name, number, ffmpegProfileId) => { - Name = name, Number = number, FFmpegProfileId = ffmpegProfileId, - StreamingMode = request.StreamingMode + var artwork = new List(); + if (!string.IsNullOrWhiteSpace(request.Logo)) + { + artwork.Add( + new Artwork + { + Path = request.Logo, + ArtworkKind = ArtworkKind.Logo, + DateAdded = DateTime.UtcNow, + DateUpdated = DateTime.UtcNow + }); + } + + return new Channel(Guid.NewGuid()) + { + Name = name, + Number = number, + FFmpegProfileId = ffmpegProfileId, + StreamingMode = request.StreamingMode, + Artwork = artwork + }; }); private Validation ValidateName(CreateChannel createChannel) =>