private void PopulateLivestreams(List <LivestreamModel> livestreamModels) { foreach (var livestream in livestreamModels) { var livestreamModel = Livestreams.FirstOrDefault(x => Equals(livestream, x)); livestreamModel?.PopulateSelf(livestream); } var newStreams = livestreamModels.Except(Livestreams).ToList(); var removedStreams = Livestreams.Except(livestreamModels).ToList(); Livestreams.AddRange(newStreams); Livestreams.RemoveRange(removedStreams); }
public async Task AddLivestream(ChannelIdentifier channelIdentifier, IViewAware viewAware) { if (channelIdentifier == null) { throw new ArgumentNullException(nameof(channelIdentifier)); } if (channelIdentifiers.Contains(channelIdentifier)) { return; // ignore duplicate requests } var livestreamQueryResults = await channelIdentifier.ApiClient.AddChannel(channelIdentifier); livestreamQueryResults.EnsureAllQuerySuccess(); AddChannels(channelIdentifier); Livestreams.AddRange(livestreamQueryResults.Select(x => x.LivestreamModel)); }