From 409945e49242fb489f9172a845ae31f5f92b5206 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 23 Mar 2018 15:54:53 +0000 Subject: [PATCH] !wip more improvments to the notification variables --- .../NotificationMessageCurlys.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/Ombi.Notifications/NotificationMessageCurlys.cs b/src/Ombi.Notifications/NotificationMessageCurlys.cs index dec98291b..8c18fba4c 100644 --- a/src/Ombi.Notifications/NotificationMessageCurlys.cs +++ b/src/Ombi.Notifications/NotificationMessageCurlys.cs @@ -1,10 +1,13 @@ using System; using System.Collections.Generic; +using System.Linq; +using System.Text; using Ombi.Helpers; using Ombi.Notifications.Models; using Ombi.Settings.Settings.Models; using Ombi.Store.Entities; using Ombi.Store.Entities.Requests; +using Ombi.Store.Repository.Requests; namespace Ombi.Notifications { @@ -73,6 +76,40 @@ namespace Ombi.Notifications $"https://image.tmdb.org/t/p/w300{req?.ParentRequest.PosterPath}" : req?.ParentRequest.PosterPath; AdditionalInformation = opts.AdditionalInformation; // DO Episode and Season Lists + + var episodes = req?.SeasonRequests?.SelectMany(x => x.Episodes) ?? new List(); + var seasons = req?.SeasonRequests?.OrderBy(x => x.SeasonNumber).ToList() ?? new List(); + var orderedEpisodes = episodes.OrderBy(x => x.EpisodeNumber).ToList(); + var epSb = new StringBuilder(); + var seasonSb = new StringBuilder(); + for (var i = 0; i < orderedEpisodes.Count; i++) + { + var ep = orderedEpisodes[i]; + if (i < orderedEpisodes.Count - 1) + { + epSb.Append($"{ep.EpisodeNumber},"); + } + else + { + epSb.Append($"{ep.EpisodeNumber}"); + } + } + + for (var i = 0; i < seasons.Count; i++) + { + var ep = seasons[i]; + if (i < seasons.Count - 1) + { + seasonSb.Append($"{ep.SeasonNumber},"); + } + else + { + seasonSb.Append($"{ep.SeasonNumber}"); + } + } + + EpisodesList = epSb.ToString(); + SeasonsList = seasonSb.ToString(); } public void Setup(OmbiUser user, CustomizationSettings s)