mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
This commit is contained in:
parent
012a82ca2d
commit
b8224f5895
12 changed files with 358 additions and 21 deletions
|
@ -18,6 +18,7 @@ namespace Ombi.Store.Context
|
|||
DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
||||
DatabaseFacade Database { get; }
|
||||
EntityEntry<T> Entry<T>(T entry) where T : class;
|
||||
EntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class;
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace Ombi.Store.Context
|
|||
public DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
public DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
public DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
public DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
||||
|
||||
public DbSet<MovieRequests> MovieRequests { get; set; }
|
||||
public DbSet<TvRequests> TvRequests { get; set; }
|
||||
|
@ -53,6 +54,12 @@ namespace Ombi.Store.Context
|
|||
.WithMany(b => b.Episodes)
|
||||
.HasPrincipalKey(x => x.Key)
|
||||
.HasForeignKey(p => p.GrandparentKey);
|
||||
|
||||
builder.Entity<EmbyEpisode>()
|
||||
.HasOne(p => p.Series)
|
||||
.WithMany(b => b.Episodes)
|
||||
.HasPrincipalKey(x => x.EmbyId)
|
||||
.HasForeignKey(p => p.ParentId);
|
||||
base.OnModelCreating(builder);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
|
@ -38,6 +39,9 @@ namespace Ombi.Store.Entities
|
|||
public string EmbyId { get; set; }
|
||||
public EmbyMediaType Type { get; set; }
|
||||
public DateTime AddedAt { get; set; }
|
||||
|
||||
|
||||
public ICollection<EmbyEpisode> Episodes { get; set; }
|
||||
}
|
||||
|
||||
public enum EmbyMediaType
|
||||
|
|
47
src/Ombi.Store/Entities/EmbyEpisode.cs
Normal file
47
src/Ombi.Store/Entities/EmbyEpisode.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2017 Jamie Rees
|
||||
// File: EmbyEpisode.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
[Table("EmbyEpisode")]
|
||||
public class EmbyEpisode : Entity
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string EmbyId { get; set; }
|
||||
public int EpisodeNumber { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public string ParentId { get; set; }
|
||||
public string ProviderId { get; set; }
|
||||
public DateTime AddedAt { get; set; }
|
||||
|
||||
public EmbyContent Series { get; set; }
|
||||
}
|
||||
}
|
|
@ -88,25 +88,26 @@ namespace Ombi.Store.Repository
|
|||
await Db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
//public IQueryable<PlexEpisode> GetAllEpisodes()
|
||||
//{
|
||||
// return Db.PlexEpisode.AsQueryable();
|
||||
//}
|
||||
public IQueryable<EmbyEpisode> GetAllEpisodes()
|
||||
{
|
||||
return Db.EmbyEpisode.AsQueryable();
|
||||
}
|
||||
|
||||
//public async Task<PlexEpisode> Add(PlexEpisode content)
|
||||
//{
|
||||
// await Db.PlexEpisode.AddAsync(content);
|
||||
// await Db.SaveChangesAsync();
|
||||
// return content;
|
||||
//}
|
||||
//public async Task<PlexEpisode> GetEpisodeByKey(int key)
|
||||
//{
|
||||
// return await Db.PlexEpisode.FirstOrDefaultAsync(x => x.Key == key);
|
||||
//}
|
||||
//public async Task AddRange(IEnumerable<PlexEpisode> content)
|
||||
//{
|
||||
// Db.PlexEpisode.AddRange(content);
|
||||
// await Db.SaveChangesAsync();
|
||||
//}
|
||||
public async Task<EmbyEpisode> Add(EmbyEpisode content)
|
||||
{
|
||||
await Db.EmbyEpisode.AddAsync(content);
|
||||
await Db.SaveChangesAsync();
|
||||
return content;
|
||||
}
|
||||
public async Task<EmbyEpisode> GetEpisodeByEmbyId(string key)
|
||||
{
|
||||
return await Db.EmbyEpisode.FirstOrDefaultAsync(x => x.EmbyId == key);
|
||||
}
|
||||
|
||||
public async Task AddRange(IEnumerable<EmbyEpisode> content)
|
||||
{
|
||||
Db.EmbyEpisode.AddRange(content);
|
||||
await Db.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,5 +15,9 @@ namespace Ombi.Store.Repository
|
|||
Task<IEnumerable<EmbyContent>> GetAll();
|
||||
Task<EmbyContent> GetByEmbyId(string embyId);
|
||||
Task Update(EmbyContent existingContent);
|
||||
IQueryable<EmbyEpisode> GetAllEpisodes();
|
||||
Task<EmbyEpisode> Add(EmbyEpisode content);
|
||||
Task<EmbyEpisode> GetEpisodeByEmbyId(string key);
|
||||
Task AddRange(IEnumerable<EmbyEpisode> content);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue