Finished the Plex Content Cacher. Need to do the episodes part but things are now showing as available! #865

This commit is contained in:
tidusjar 2017-05-21 00:13:07 +01:00
commit df5f0fc691
13 changed files with 143 additions and 75 deletions

View file

@ -15,8 +15,7 @@ namespace Ombi.Store.Context
DbSet<GlobalSettings> Settings { get; set; }
DbSet<PlexContent> PlexContent { get; set; }
DbSet<User> Users { get; set; }
EntityEntry<GlobalSettings> Entry(GlobalSettings settings);
EntityEntry<User> Entry(User settings);
EntityEntry<T> Entry<T>(T entry) where T : class;
EntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class;
}
}

View file

@ -37,14 +37,9 @@ namespace Ombi.Store.Context
public DbSet<PlexContent> PlexContent { get; set; }
public EntityEntry<GlobalSettings> Entry(GlobalSettings settings)
public EntityEntry<T> Entry<T>(T entry) where T : class
{
return base.Entry(settings);
}
public EntityEntry<User> Entry(User settings)
{
return base.Entry(settings);
return base.Entry(entry);
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

View file

@ -44,7 +44,7 @@ namespace Ombi.Store.Entities
/// <summary>
/// Only used for TV Shows
/// </summary>
public List<SeasonsContent> Seasons { get; set; }
public virtual ICollection<SeasonsContent> Seasons { get; set; }
/// <summary>
/// Plex's internal ID for this item
@ -55,6 +55,7 @@ namespace Ombi.Store.Entities
public class SeasonsContent : Entity
{
public int PlexContentId { get; set; }
public int SeasonNumber { get; set; }
public int SeasonKey { get; set; }
public int ParentKey { get; set; }

View file

@ -50,7 +50,7 @@ namespace Ombi.Store.Repository
public async Task AddRange(IEnumerable<PlexContent> content)
{
await Db.PlexContent.AddRangeAsync(content);
Db.PlexContent.AddRange(content);
await Db.SaveChangesAsync();
}
@ -73,7 +73,7 @@ namespace Ombi.Store.Repository
public async Task<PlexContent> GetByKey(string key)
{
return await Db.PlexContent.FirstOrDefaultAsync(x => x.Key == key);
return await Db.PlexContent.Include(x => x.Seasons).FirstOrDefaultAsync(x => x.Key == key);
}
public async Task Update(PlexContent existingContent)