mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
Damn son. So many changes... Fixed alot of stuff around tv episodes with the new DB model #865
This commit is contained in:
parent
1a7f81b16c
commit
0875b5f665
40 changed files with 340 additions and 874 deletions
|
@ -13,7 +13,6 @@ namespace Ombi.Store.Context
|
|||
{
|
||||
int SaveChanges();
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
|
||||
DbSet<RequestBlobs> Requests { get; set; }
|
||||
DbSet<GlobalSettings> Settings { get; set; }
|
||||
DbSet<PlexContent> PlexContent { get; set; }
|
||||
DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
|
|
|
@ -34,8 +34,7 @@ namespace Ombi.Store.Context
|
|||
// Add the notifcation templates
|
||||
AddAllTemplates();
|
||||
}
|
||||
|
||||
public DbSet<RequestBlobs> Requests { get; set; }
|
||||
|
||||
public DbSet<GlobalSettings> Settings { get; set; }
|
||||
public DbSet<User> Users { get; set; }
|
||||
public DbSet<PlexContent> PlexContent { get; set; }
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
[Table("RequestBlobs")]
|
||||
public class RequestBlobs : Entity
|
||||
{
|
||||
public int ProviderId { get; set; }
|
||||
public byte[] Content { get; set; }
|
||||
public RequestType Type { get; set; }
|
||||
|
||||
}
|
||||
public enum RequestType
|
||||
{
|
||||
Movie = 1,
|
||||
TvShow = 2
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
public class RequestHistory : Entity
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
public RequestType Type { get; set; }
|
||||
public DateTime RequestedDate { get; set; }
|
||||
public int RequestId { get; set; }
|
||||
|
||||
public virtual RequestBlobs Request { get; set; }
|
||||
public virtual User User { get; set; }
|
||||
}
|
||||
}
|
12
src/Ombi.Store/Entities/RequestType.cs
Normal file
12
src/Ombi.Store/Entities/RequestType.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
public enum RequestType
|
||||
{
|
||||
TvShow,
|
||||
Movie
|
||||
}
|
||||
}
|
|
@ -24,8 +24,10 @@ namespace Ombi.Store.Repository.Requests
|
|||
public DateTime AirDate { get; set; }
|
||||
public string Url { get; set; }
|
||||
public bool Available { get; set; }
|
||||
|
||||
|
||||
public bool Approved { get; set; }
|
||||
public bool Requested { get; set; }
|
||||
|
||||
|
||||
public int SeasonId { get; set; }
|
||||
[ForeignKey(nameof(SeasonId))]
|
||||
public SeasonRequests Season { get; set; }
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public interface IRequestRepository
|
||||
{
|
||||
void Delete(RequestBlobs entity);
|
||||
void DeleteAll(IEnumerable<RequestBlobs> entity);
|
||||
RequestBlobs Get(int id);
|
||||
IEnumerable<RequestBlobs> GetAll();
|
||||
Task<IEnumerable<RequestBlobs>> GetAllAsync();
|
||||
Task<RequestBlobs> GetAsync(int id);
|
||||
RequestBlobs Insert(RequestBlobs entity);
|
||||
Task<RequestBlobs> InsertAsync(RequestBlobs entity);
|
||||
RequestBlobs Update(RequestBlobs entity);
|
||||
void UpdateAll(IEnumerable<RequestBlobs> entity);
|
||||
IQueryable<RequestBlobs> GetAllQueryable();
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class RequestJsonRepository : IRequestRepository
|
||||
{
|
||||
//private ICacheProvider Cache { get; }
|
||||
|
||||
public RequestJsonRepository(IOmbiContext ctx)
|
||||
{
|
||||
Db = ctx;
|
||||
}
|
||||
|
||||
private IOmbiContext Db { get; }
|
||||
|
||||
public RequestBlobs Insert(RequestBlobs entity)
|
||||
{
|
||||
|
||||
var id = Db.Requests.Add(entity);
|
||||
Db.SaveChanges();
|
||||
return id.Entity;
|
||||
|
||||
}
|
||||
|
||||
public async Task<RequestBlobs> InsertAsync(RequestBlobs entity)
|
||||
{
|
||||
|
||||
var id = await Db.Requests.AddAsync(entity).ConfigureAwait(false);
|
||||
await Db.SaveChangesAsync();
|
||||
return id.Entity;
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<RequestBlobs> GetAll()
|
||||
{
|
||||
//var key = "GetAll";
|
||||
//var item = Cache.GetOrSet(key, () =>
|
||||
//{
|
||||
|
||||
var page = Db.Requests.ToList();
|
||||
return page;
|
||||
|
||||
//}, 5);
|
||||
//return item;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RequestBlobs>> GetAllAsync()
|
||||
{
|
||||
//var key = "GetAll";
|
||||
//var item = await Cache.GetOrSetAsync(key, async () =>
|
||||
//{
|
||||
|
||||
var page = await Db.Requests.ToListAsync().ConfigureAwait(false);
|
||||
return page;
|
||||
|
||||
//}, 5);
|
||||
//return item;
|
||||
}
|
||||
|
||||
public RequestBlobs Get(int id)
|
||||
{
|
||||
//var key = "Get" + id;
|
||||
//var item = Cache.GetOrSet(key, () =>
|
||||
//{
|
||||
|
||||
var page = Db.Requests.Find(id);
|
||||
return page;
|
||||
|
||||
//}, 5);
|
||||
//return item;
|
||||
}
|
||||
|
||||
public async Task<RequestBlobs> GetAsync(int id)
|
||||
{
|
||||
//var key = "Get" + id;
|
||||
//var item = await Cache.GetOrSetAsync(key, async () =>
|
||||
//{
|
||||
|
||||
var page = await Db.Requests.FindAsync(id).ConfigureAwait(false);
|
||||
return page;
|
||||
|
||||
//}, 5);
|
||||
//return item;
|
||||
}
|
||||
|
||||
public void Delete(RequestBlobs entity)
|
||||
{
|
||||
//ResetCache();
|
||||
|
||||
Db.Requests.Remove(entity);
|
||||
Db.SaveChanges();
|
||||
|
||||
}
|
||||
|
||||
public RequestBlobs Update(RequestBlobs entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
Db.SaveChanges();
|
||||
|
||||
return entity;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void UpdateAll(IEnumerable<RequestBlobs> entity)
|
||||
{
|
||||
|
||||
Db.Requests.UpdateRange(entity);
|
||||
Db.SaveChanges();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void DeleteAll(IEnumerable<RequestBlobs> entity)
|
||||
{
|
||||
|
||||
Db.Requests.RemoveRange(entity);
|
||||
Db.SaveChanges();
|
||||
|
||||
}
|
||||
|
||||
public IQueryable<RequestBlobs> GetAllQueryable()
|
||||
{
|
||||
return Db.Requests.AsQueryable();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -167,6 +167,8 @@ CREATE TABLE IF NOT EXISTS EpisodeRequests (
|
|||
Url VARCHAR(100) NOT NULL,
|
||||
SeasonId INTEGER NOT NULL,
|
||||
Available INTEGER NOT NULL,
|
||||
Requested INTEGER NOT NULL,
|
||||
Approved INTEGER NOT NULL,
|
||||
|
||||
|
||||
FOREIGN KEY (SeasonId) REFERENCES SeasonRequests(Id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue