diff --git a/src/Ombi.Core/Engine/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index 1c25bdec4..37292ac64 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -128,13 +128,21 @@ namespace Ombi.Core.Engine public async Task> GetRequests(int count, int position) { - var allRequests = await TvRepository.Get().Skip(position).Take(count).ToListAsync(); + var allRequests = await TvRepository.Get() + .Include(x => x.ChildRequests) + .ThenInclude(x => x.SeasonRequests) + .ThenInclude(x => x.Episodes) + .Skip(position).Take(count).ToListAsync(); return allRequests; } public async Task>>> GetRequestsTreeNode(int count, int position) { - var allRequests = await TvRepository.Get().Skip(position).Take(count).ToListAsync(); + var allRequests = await TvRepository.Get() + .Include(x => x.ChildRequests) + .ThenInclude(x => x.SeasonRequests) + .ThenInclude(x=>x.Episodes) + .Skip(position).Take(count).ToListAsync(); return ParseIntoTreeNode(allRequests); } @@ -146,7 +154,7 @@ namespace Ombi.Core.Engine public async Task> GetAllChldren(int tvId) { - return await TvRepository.GetChild().Where(x => x.ParentRequestId == tvId).ToListAsync(); + return await TvRepository.GetChild().Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync(); } public async Task> SearchTvRequest(string search) diff --git a/src/Ombi.Core/Senders/TvSender.cs b/src/Ombi.Core/Senders/TvSender.cs index d2fc19683..46fa14470 100644 --- a/src/Ombi.Core/Senders/TvSender.cs +++ b/src/Ombi.Core/Senders/TvSender.cs @@ -111,7 +111,7 @@ namespace Ombi.Core.Senders { foreach (var ep in req.Episodes) { - var sonarrEp = sonarrEpisodes.FirstOrDefault(x => x.episodeNumber == ep.EpisodeNumber && x.seasonNumber == ep.Season.SeasonNumber); + var sonarrEp = sonarrEpisodes.FirstOrDefault(x => x.episodeNumber == ep.EpisodeNumber && x.seasonNumber == req.SeasonNumber); if (sonarrEp != null) { sonarrEp.monitored = true; diff --git a/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs b/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs index a89a88dec..bfb85ce53 100644 --- a/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs @@ -99,6 +99,7 @@ namespace Ombi.Store.Repository.Requests public async Task UpdateChild(ChildRequests request) { Db.Attach(request).State = EntityState.Modified; + Db.Attach(request.SeasonRequests).State = EntityState.Modified; await Db.SaveChangesAsync(); }