diff --git a/src/Ombi.Api.Plex/IPlexApi.cs b/src/Ombi.Api.Plex/IPlexApi.cs index a80c02d67..0c7bbe11f 100644 --- a/src/Ombi.Api.Plex/IPlexApi.cs +++ b/src/Ombi.Api.Plex/IPlexApi.cs @@ -12,9 +12,9 @@ namespace Ombi.Api.Plex Task GetServer(string authToken); Task GetLibrarySections(string authToken, string plexFullHost); Task GetLibrary(string authToken, string plexFullHost, string libraryId); - Task GetEpisodeMetaData(string authToken, string host, string ratingKey); - Task GetMetadata(string authToken, string plexFullHost, string itemId); - Task GetSeasons(string authToken, string plexFullHost, string ratingKey); + Task GetEpisodeMetaData(string authToken, string host, int ratingKey); + Task GetMetadata(string authToken, string plexFullHost, int itemId); + Task GetSeasons(string authToken, string plexFullHost, int ratingKey); Task GetAllEpisodes(string authToken, string host, string section, int start, int retCount); } } \ No newline at end of file diff --git a/src/Ombi.Api.Plex/Models/Metadata.cs b/src/Ombi.Api.Plex/Models/Metadata.cs index 0d803901f..e7fda9962 100644 --- a/src/Ombi.Api.Plex/Models/Metadata.cs +++ b/src/Ombi.Api.Plex/Models/Metadata.cs @@ -2,7 +2,7 @@ namespace Ombi.Api.Plex.Models { public class Metadata { - public string ratingKey { get; set; } + public int ratingKey { get; set; } public string key { get; set; } public string studio { get; set; } public string type { get; set; } @@ -28,8 +28,8 @@ namespace Ombi.Api.Plex.Models public Genre[] Genre { get; set; } public Role[] Role { get; set; } public string primaryExtraKey { get; set; } - public string parentRatingKey { get; set; } - public string grandparentRatingKey { get; set; } + public int parentRatingKey { get; set; } + public int grandparentRatingKey { get; set; } public string guid { get; set; } public int librarySectionID { get; set; } public string librarySectionKey { get; set; } diff --git a/src/Ombi.Api.Plex/PlexApi.cs b/src/Ombi.Api.Plex/PlexApi.cs index 34748096d..2609a51f7 100644 --- a/src/Ombi.Api.Plex/PlexApi.cs +++ b/src/Ombi.Api.Plex/PlexApi.cs @@ -85,21 +85,21 @@ namespace Ombi.Api.Plex /// /// /// - public async Task GetEpisodeMetaData(string authToken, string plexFullHost, string ratingKey) + public async Task GetEpisodeMetaData(string authToken, string plexFullHost, int ratingKey) { var request = new Request($"/library/metadata/{ratingKey}", plexFullHost, HttpMethod.Get); AddHeaders(request, authToken); return await Api.Request(request); } - public async Task GetMetadata(string authToken, string plexFullHost, string itemId) + public async Task GetMetadata(string authToken, string plexFullHost, int itemId) { var request = new Request($"library/metadata/{itemId}", plexFullHost, HttpMethod.Get); AddHeaders(request, authToken); return await Api.Request(request); } - public async Task GetSeasons(string authToken, string plexFullHost, string ratingKey) + public async Task GetSeasons(string authToken, string plexFullHost, int ratingKey) { var request = new Request($"library/metadata/{ratingKey}/children", plexFullHost, HttpMethod.Get); AddHeaders(request, authToken); diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs index 05e33be05..de488fbd2 100644 --- a/src/Ombi.DependencyInjection/IocExtensions.cs +++ b/src/Ombi.DependencyInjection/IocExtensions.cs @@ -123,6 +123,7 @@ namespace Ombi.DependencyInjection { services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/src/Ombi.Helpers/PlexHelper.cs b/src/Ombi.Helpers/PlexHelper.cs index 5149ec8f6..9eb938c70 100644 --- a/src/Ombi.Helpers/PlexHelper.cs +++ b/src/Ombi.Helpers/PlexHelper.cs @@ -91,7 +91,7 @@ namespace Ombi.Helpers return 0; } - public static string GetPlexMediaUrl(string machineId, string mediaId) + public static string GetPlexMediaUrl(string machineId, int mediaId) { var url = $"https://app.plex.tv/web/app#!/server/{machineId}/details?key=library%2Fmetadata%2F{mediaId}"; diff --git a/src/Ombi.Schedule/IPlexAvailabilityChecker.cs b/src/Ombi.Schedule/IPlexAvailabilityChecker.cs new file mode 100644 index 000000000..0f65ddeb8 --- /dev/null +++ b/src/Ombi.Schedule/IPlexAvailabilityChecker.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace Ombi.Schedule.Jobs.Plex +{ + public interface IPlexAvailabilityChecker + { + Task Start(); + } +} \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Plex/IPlexContentCacher.cs b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexContentCacher.cs similarity index 100% rename from src/Ombi.Schedule/Jobs/Plex/IPlexContentCacher.cs rename to src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexContentCacher.cs diff --git a/src/Ombi.Schedule/Jobs/Plex/IPlexEpisodeCacher.cs b/src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexEpisodeCacher.cs similarity index 100% rename from src/Ombi.Schedule/Jobs/Plex/IPlexEpisodeCacher.cs rename to src/Ombi.Schedule/Jobs/Plex/Interfaces/IPlexEpisodeCacher.cs diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs b/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs new file mode 100644 index 000000000..19ddeb0e1 --- /dev/null +++ b/src/Ombi.Schedule/Jobs/Plex/PlexAvailabilityChecker.cs @@ -0,0 +1,84 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Ombi.Store.Repository; +using Ombi.Store.Repository.Requests; + +namespace Ombi.Schedule.Jobs.Plex +{ + public class PlexAvailabilityChecker : IPlexAvailabilityChecker + { + public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies) + { + _tvRepo = tvRequest; + _repo = repo; + _movieRepo = movies; + } + + private readonly ITvRequestRepository _tvRepo; + private readonly IMovieRequestRepository _movieRepo; + private readonly IPlexContentRepository _repo; + + public async Task Start() + { + await ProcessMovies(); + await ProcessTv(); + } + + private async Task ProcessTv() + { + var tv = _tvRepo.GetChild(); + var plexEpisodes = _repo.GetAllEpisodes().Include(x => x.Series); + + foreach (var child in tv) + { + var tvDbId = child.ParentRequest.TvDbId; + var seriesEpisodes = plexEpisodes.Where(x => x.Series.ProviderId == tvDbId.ToString()); + foreach (var season in child.SeasonRequests) + { + foreach (var episode in season.Episodes) + { + var foundEp = await seriesEpisodes.FirstOrDefaultAsync( + x => x.EpisodeNumber == episode.EpisodeNumber && + x.SeasonNumber == episode.Season.SeasonNumber); + + if (foundEp != null) + { + episode.Available = true; + } + } + } + + // Check to see if all of the episodes in all seasons are available for this request + var allAvailable = child.SeasonRequests.All(x => x.Episodes.All(c => c.Available)); + if (allAvailable) + { + // We have fulfulled this request! + child.Available = true; + } + } + + await _tvRepo.Save(); + } + + private async Task ProcessMovies() + { + // Get all non available + var movies = _movieRepo.Get().Where(x => !x.Available); + + foreach (var movie in movies) + { + var plexContent = await _repo.Get(movie.ImdbId); + if (plexContent == null) + { + // We don't yet have this + continue; + } + + movie.Available = true; + } + + await _movieRepo.Save(); + } + } +} \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs b/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs index 92a503429..dfa8302b5 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexContentCacher.cs @@ -107,10 +107,10 @@ namespace Ombi.Schedule.Jobs.Plex { seasonsContent.Add(new PlexSeasonsContent { - ParentKey = int.Parse(season.parentRatingKey), - SeasonKey = int.Parse(season.ratingKey), + ParentKey = season.parentRatingKey, + SeasonKey = season.ratingKey, SeasonNumber = season.index, - PlexContentId = int.Parse(show.ratingKey) + PlexContentId = show.ratingKey }); } @@ -197,8 +197,7 @@ namespace Ombi.Schedule.Jobs.Plex if (contentToAdd.Any()) { - - contentToAdd.ForEach(async x => await Repo.Add(x)); + await Repo.AddRange(contentToAdd); } } diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs b/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs index 57e3a0ae6..c4d24e065 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexEpisodeCacher.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Hangfire; using Hangfire.Common; using Microsoft.Extensions.Logging; using Ombi.Api.Plex; @@ -19,19 +20,21 @@ namespace Ombi.Schedule.Jobs.Plex public class PlexEpisodeCacher : IPlexEpisodeCacher { public PlexEpisodeCacher(ISettingsService s, ILogger log, IPlexApi plexApi, - IPlexContentRepository repo) + IPlexContentRepository repo, IPlexAvailabilityChecker a) { _settings = s; _log = log; _api = plexApi; _repo = repo; + _availabilityChecker = a; } private readonly ISettingsService _settings; private readonly ILogger _log; private readonly IPlexApi _api; private readonly IPlexContentRepository _repo; - + private readonly IPlexAvailabilityChecker _availabilityChecker; + public async Task Start() { try @@ -46,6 +49,7 @@ namespace Ombi.Schedule.Jobs.Plex { await Cache(server); + BackgroundJob.Enqueue(() => _availabilityChecker.Start()); } } catch (Exception e) diff --git a/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs b/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs index f8437d502..021d612b8 100644 --- a/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs +++ b/src/Ombi.Schedule/Jobs/Radarr/RadarrCacher.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; @@ -29,38 +30,45 @@ namespace Ombi.Schedule.Jobs.Radarr public async Task CacheContent() { - var settings = RadarrSettings.GetSettings(); - if (settings.Enabled) + try { - try + var settings = RadarrSettings.GetSettings(); + if (settings.Enabled) { - var movies = await RadarrApi.GetMovies(settings.ApiKey, settings.FullUri); - if (movies != null) + try { - // Let's remove the old cached data - await _ctx.Database.ExecuteSqlCommandAsync("TRUNCATE TABLE RadarrCache"); - - var movieIds = new List(); - foreach (var m in movies) + var movies = await RadarrApi.GetMovies(settings.ApiKey, settings.FullUri); + if (movies != null) { - if (m.tmdbId > 0) - { - movieIds.Add(new RadarrCache{TheMovieDbId = m.tmdbId}); - } - else + // Let's remove the old cached data + await _ctx.Database.ExecuteSqlCommandAsync("TRUNCATE TABLE RadarrCache"); + + var movieIds = new List(); + foreach (var m in movies) { - Log.Error("TMDBId is not > 0 for movie {0}", m.title); + if (m.tmdbId > 0) + { + movieIds.Add(new RadarrCache { TheMovieDbId = m.tmdbId }); + } + else + { + Log.Error("TMDBId is not > 0 for movie {0}", m.title); + } } - } - await _ctx.RadarrCache.AddRangeAsync(movieIds); + await _ctx.RadarrCache.AddRangeAsync(movieIds); - await _ctx.SaveChangesAsync(); + await _ctx.SaveChangesAsync(); + } + } + catch (System.Exception ex) + { + Logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Radarr"); } } - catch (System.Exception ex) - { - Logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Radarr"); - } + } + catch (Exception e) + { + Logger.LogInformation(LoggingEvents.RadarrCacher, "Radarr is not setup, cannot cache episodes"); } } diff --git a/src/Ombi.Store/Context/OmbiContext.cs b/src/Ombi.Store/Context/OmbiContext.cs index 81502e6ee..823e56021 100644 --- a/src/Ombi.Store/Context/OmbiContext.cs +++ b/src/Ombi.Store/Context/OmbiContext.cs @@ -45,6 +45,16 @@ namespace Ombi.Store.Context optionsBuilder.UseSqlite("Data Source=Ombi.db"); } + protected override void OnModelCreating(ModelBuilder builder) + { + builder.Entity() + .HasOne(p => p.Series) + .WithMany(b => b.Episodes) + .HasPrincipalKey(x => x.Key) + .HasForeignKey(p => p.GrandparentKey); + base.OnModelCreating(builder); + } + public void Seed() { diff --git a/src/Ombi.Store/Entities/PlexContent.cs b/src/Ombi.Store/Entities/PlexContent.cs index 211b2e611..e07d2e179 100644 --- a/src/Ombi.Store/Entities/PlexContent.cs +++ b/src/Ombi.Store/Entities/PlexContent.cs @@ -45,11 +45,13 @@ namespace Ombi.Store.Entities /// Only used for TV Shows /// public virtual ICollection Seasons { get; set; } + + public ICollection Episodes { get; set; } /// /// Plex's internal ID for this item /// - public string Key { get; set; } + public int Key { get; set; } public DateTime AddedAt { get; set; } } diff --git a/src/Ombi.Store/Entities/PlexEpisode.cs b/src/Ombi.Store/Entities/PlexEpisode.cs index 161184f63..ecd03742c 100644 --- a/src/Ombi.Store/Entities/PlexEpisode.cs +++ b/src/Ombi.Store/Entities/PlexEpisode.cs @@ -7,21 +7,24 @@ namespace Ombi.Store.Entities { public int EpisodeNumber { get; set; } public int SeasonNumber { get; set; } - public string Key { get; set; } // RatingKey + public int Key { get; set; } // RatingKey public string Title { get; set; } /// - /// The Show key + /// The Season key /// /// /// The parent key. /// - public string ParentKey { get; set; } + public int ParentKey { get; set; } /// /// The Series key /// /// /// The grandparent key. /// - public string GrandparentKey { get; set; } + public int GrandparentKey { get; set; } + + + public PlexContent Series { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Store/Migrations/20170823144220_Inital.Designer.cs b/src/Ombi.Store/Migrations/20170824133349_Inital.Designer.cs similarity index 96% rename from src/Ombi.Store/Migrations/20170823144220_Inital.Designer.cs rename to src/Ombi.Store/Migrations/20170824133349_Inital.Designer.cs index 5af0be140..6c555ca10 100644 --- a/src/Ombi.Store/Migrations/20170823144220_Inital.Designer.cs +++ b/src/Ombi.Store/Migrations/20170824133349_Inital.Designer.cs @@ -10,7 +10,7 @@ using Ombi.Helpers; namespace Ombi.Store.Migrations { [DbContext(typeof(OmbiContext))] - [Migration("20170823144220_Inital")] + [Migration("20170824133349_Inital")] partial class Inital { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -254,7 +254,7 @@ namespace Ombi.Store.Migrations b.Property("AddedAt"); - b.Property("Key"); + b.Property("Key"); b.Property("ProviderId"); @@ -278,11 +278,11 @@ namespace Ombi.Store.Migrations b.Property("EpisodeNumber"); - b.Property("GrandparentKey"); + b.Property("GrandparentKey"); - b.Property("Key"); + b.Property("Key"); - b.Property("ParentKey"); + b.Property("ParentKey"); b.Property("SeasonNumber"); @@ -290,6 +290,8 @@ namespace Ombi.Store.Migrations b.HasKey("Id"); + b.HasIndex("GrandparentKey"); + b.ToTable("PlexEpisode"); }); @@ -568,6 +570,15 @@ namespace Ombi.Store.Migrations .OnDelete(DeleteBehavior.Cascade); }); + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.HasOne("Ombi.Store.Entities.PlexContent", "Series") + .WithMany("Episodes") + .HasForeignKey("GrandparentKey") + .HasPrincipalKey("Key") + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => { b.HasOne("Ombi.Store.Entities.PlexContent") diff --git a/src/Ombi.Store/Migrations/20170823144220_Inital.cs b/src/Ombi.Store/Migrations/20170824133349_Inital.cs similarity index 97% rename from src/Ombi.Store/Migrations/20170823144220_Inital.cs rename to src/Ombi.Store/Migrations/20170824133349_Inital.cs index f65bbb76f..3e321b694 100644 --- a/src/Ombi.Store/Migrations/20170823144220_Inital.cs +++ b/src/Ombi.Store/Migrations/20170824133349_Inital.cs @@ -132,7 +132,7 @@ namespace Ombi.Store.Migrations Id = table.Column(nullable: false) .Annotation("Sqlite:Autoincrement", true), AddedAt = table.Column(nullable: false), - Key = table.Column(nullable: true), + Key = table.Column(nullable: false), ProviderId = table.Column(nullable: true), ReleaseYear = table.Column(nullable: true), Title = table.Column(nullable: true), @@ -142,24 +142,7 @@ namespace Ombi.Store.Migrations constraints: table => { table.PrimaryKey("PK_PlexContent", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "PlexEpisode", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - EpisodeNumber = table.Column(nullable: false), - GrandparentKey = table.Column(nullable: true), - Key = table.Column(nullable: true), - ParentKey = table.Column(nullable: true), - SeasonNumber = table.Column(nullable: false), - Title = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_PlexEpisode", x => x.Id); + table.UniqueConstraint("AK_PlexContent_Key", x => x.Key); }); migrationBuilder.CreateTable( @@ -334,6 +317,30 @@ namespace Ombi.Store.Migrations onDelete: ReferentialAction.Restrict); }); + migrationBuilder.CreateTable( + name: "PlexEpisode", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + EpisodeNumber = table.Column(nullable: false), + GrandparentKey = table.Column(nullable: false), + Key = table.Column(nullable: false), + ParentKey = table.Column(nullable: false), + SeasonNumber = table.Column(nullable: false), + Title = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PlexEpisode", x => x.Id); + table.ForeignKey( + name: "FK_PlexEpisode_PlexContent_GrandparentKey", + column: x => x.GrandparentKey, + principalTable: "PlexContent", + principalColumn: "Key", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "PlexSeasonsContent", columns: table => new @@ -529,6 +536,11 @@ namespace Ombi.Store.Migrations column: "NormalizedUserName", unique: true); + migrationBuilder.CreateIndex( + name: "IX_PlexEpisode_GrandparentKey", + table: "PlexEpisode", + column: "GrandparentKey"); + migrationBuilder.CreateIndex( name: "IX_PlexSeasonsContent_PlexContentId", table: "PlexSeasonsContent", diff --git a/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs b/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs index a25e0d1b2..4270f62a0 100644 --- a/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs +++ b/src/Ombi.Store/Migrations/OmbiContextModelSnapshot.cs @@ -253,7 +253,7 @@ namespace Ombi.Store.Migrations b.Property("AddedAt"); - b.Property("Key"); + b.Property("Key"); b.Property("ProviderId"); @@ -277,11 +277,11 @@ namespace Ombi.Store.Migrations b.Property("EpisodeNumber"); - b.Property("GrandparentKey"); + b.Property("GrandparentKey"); - b.Property("Key"); + b.Property("Key"); - b.Property("ParentKey"); + b.Property("ParentKey"); b.Property("SeasonNumber"); @@ -289,6 +289,8 @@ namespace Ombi.Store.Migrations b.HasKey("Id"); + b.HasIndex("GrandparentKey"); + b.ToTable("PlexEpisode"); }); @@ -567,6 +569,15 @@ namespace Ombi.Store.Migrations .OnDelete(DeleteBehavior.Cascade); }); + modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b => + { + b.HasOne("Ombi.Store.Entities.PlexContent", "Series") + .WithMany("Episodes") + .HasForeignKey("GrandparentKey") + .HasPrincipalKey("Key") + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b => { b.HasOne("Ombi.Store.Entities.PlexContent") diff --git a/src/Ombi.Store/Repository/IPlexContentRepository.cs b/src/Ombi.Store/Repository/IPlexContentRepository.cs index ac7d60155..85e61d38e 100644 --- a/src/Ombi.Store/Repository/IPlexContentRepository.cs +++ b/src/Ombi.Store/Repository/IPlexContentRepository.cs @@ -12,11 +12,12 @@ namespace Ombi.Store.Repository Task ContentExists(string providerId); Task> GetAll(); Task Get(string providerId); - Task GetByKey(string key); + Task GetByKey(int key); Task Update(PlexContent existingContent); IQueryable GetAllEpisodes(); Task Add(PlexEpisode content); - Task GetEpisodeByKey(string key); + Task GetEpisodeByKey(int key); Task AddRange(IEnumerable content); + IQueryable Get(); } } \ No newline at end of file diff --git a/src/Ombi.Store/Repository/PlexContentRepository.cs b/src/Ombi.Store/Repository/PlexContentRepository.cs index 232513863..196d47021 100644 --- a/src/Ombi.Store/Repository/PlexContentRepository.cs +++ b/src/Ombi.Store/Repository/PlexContentRepository.cs @@ -72,7 +72,12 @@ namespace Ombi.Store.Repository return await Db.PlexContent.FirstOrDefaultAsync(x => x.ProviderId == providerId); } - public async Task GetByKey(string key) + public IQueryable Get() + { + return Db.PlexContent.AsQueryable(); + } + + public async Task GetByKey(int key) { return await Db.PlexContent.Include(x => x.Seasons).FirstOrDefaultAsync(x => x.Key == key); } @@ -94,7 +99,7 @@ namespace Ombi.Store.Repository await Db.SaveChangesAsync(); return content; } - public async Task GetEpisodeByKey(string key) + public async Task GetEpisodeByKey(int key) { return await Db.PlexEpisode.FirstOrDefaultAsync(x => x.Key == key); } diff --git a/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs b/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs index b73aff999..3d5f0c078 100644 --- a/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs @@ -11,5 +11,6 @@ namespace Ombi.Store.Repository IQueryable Get(); Task GetRequest(int theMovieDbId); Task Update(MovieRequests request); + Task Save(); } } \ No newline at end of file diff --git a/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs b/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs index cd524e3b6..5a294653a 100644 --- a/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs @@ -15,5 +15,6 @@ namespace Ombi.Store.Repository.Requests Task Update(TvRequests request); Task UpdateChild(ChildRequests request); IQueryable GetChild(); + Task Save(); } } \ No newline at end of file diff --git a/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs b/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs index 9b18dbad9..2f3ab507b 100644 --- a/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Ombi.Store.Context; @@ -46,5 +47,10 @@ namespace Ombi.Store.Repository.Requests { await Db.SaveChangesAsync(); } - } + + public async Task Save() + { + await Db.SaveChangesAsync(); + } + } } \ No newline at end of file diff --git a/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs b/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs index ce535b421..09424d20d 100644 --- a/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs @@ -45,6 +45,11 @@ namespace Ombi.Store.Repository.Requests .AsQueryable(); } + public async Task Save() + { + await Db.SaveChangesAsync(); + } + public async Task Add(TvRequests request) { await Db.TvRequests.AddAsync(request);