public async Task <List <EpisodeDto> > PreviousEpisodeSeen(string showTitle, int seasonNum, int episodeNum, int userid) { //a látott sorozatokat és magát a sorozatot keresem ki ahol egyezik az id var model = await _seriesRepository.GetSeriesByStartedEpisode(showTitle, seasonNum, episodeNum, userid); var foundSeries = new InternalSeries(); foreach (var internalSeries in model.foundSeriesList) { if (int.Parse(internalSeries.TvMazeId) == model.startedEpisodesList.TvMazeId || int.Parse(internalSeries.TmdbId) == model.startedEpisodesList.TmdbId) { foundSeries = internalSeries; } } if (foundSeries != null) { //id-k tryparsolása külön if (foundSeries.TvMazeId == null) { foundSeries.TvMazeId = "0"; } if (foundSeries.TmdbId == null) { foundSeries.TmdbId = "0"; } var seenEpisodesInternal = await _seriesRepository.PreviousEpisodeSeen(seasonNum, episodeNum, int.Parse(foundSeries.TvMazeId), int.Parse(foundSeries.TmdbId), userid); //ebbe fogom gyűjteni azokat az epizódszámokat amelyeket nem láttunk var notSeenEpisodes = new List <int>(); //ha nem láttuk az összes előzőleges részt if (seenEpisodesInternal.Count != episodeNum - 1) { int episodeCounter = foundSeries.Seasons[seasonNum].Episodes.First().EpisodeNumber; //megnézzük melyiket nem láttuk foreach (var seenEpisodeInternal in seenEpisodesInternal) { if (seenEpisodeInternal.EpisodeNumber != episodeCounter) { foundSeries.Seasons[seasonNum].Episodes .RemoveAll(x => x.SeasonNumber == seenEpisodeInternal.SeasonNumber && x.EpisodeNumber == seenEpisodeInternal.EpisodeNumber || x.EpisodeNumber > episodeNum); notSeenEpisodes.Add(episodeCounter); } episodeCounter++; } //a notSeenEpisodes lista intjei alapján kikeresem azokat a részeket amiket nem láttunk, a returnhoz //var notseen = await _repo.GetNotSeenEpisodes(seasonNum, notSeenEpisodes, Int32.Parse(foundSeries.TvMazeId), Int32.Parse(foundSeries.TmdbId)); return(foundSeries.Seasons[seasonNum].Episodes.Select(x => new EpisodeDto() { Title = x.Title, AirDate = x.AirDate, Crew = x.Crew.Select(crew => new EpisodeCrewDto() { Name = crew.Name, Department = crew.Department, Job = crew.Job }).ToList(), Description = x.Description, GuestStars = x.GuestStars.Select(stars => new EpisodeGuestDto() { Name = stars.Name, Character = stars.Character }).ToList(), Length = x.Length, TmdbShowId = x.TmdbShowId }).ToList()); } } throw new InternalException(615, "No recommendation were done."); //return null; }