mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
A lot of clean up and added a new Image api #865
This commit is contained in:
parent
69d75976c5
commit
1eb18b3187
32 changed files with 454 additions and 61 deletions
|
@ -23,7 +23,7 @@ namespace Ombi.Store.Context
|
|||
DbSet<NotificationTemplates> NotificationTemplates { get; set; }
|
||||
DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
void Seed();
|
||||
|
||||
DbSet<Audit> Audit { get; set; }
|
||||
DbSet<MovieRequests> MovieRequests { get; set; }
|
||||
DbSet<TvRequests> TvRequests { get; set; }
|
||||
DbSet<ChildRequests> ChildRequests { get; set; }
|
||||
|
|
|
@ -34,6 +34,8 @@ namespace Ombi.Store.Context
|
|||
public DbSet<MovieIssues> MovieIssues { get; set; }
|
||||
public DbSet<TvIssues> TvIssues { get; set; }
|
||||
|
||||
public DbSet<Audit> Audit { get; set; }
|
||||
|
||||
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
|
@ -44,6 +46,30 @@ namespace Ombi.Store.Context
|
|||
|
||||
public void Seed()
|
||||
{
|
||||
|
||||
// Add the tokens
|
||||
var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||
if (fanArt == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.FanartTv,
|
||||
Value = "4b6d983efa54d8f45c68432521335f15"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||
if (movieDb == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.TheMovieDb,
|
||||
Value = "b8eabaf5608b88d0298aa189dd90bf00"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
// Check if templates exist
|
||||
var templates = NotificationTemplates.ToList();
|
||||
if (templates.Any())
|
||||
|
|
|
@ -13,5 +13,7 @@ namespace Ombi.Store.Entities
|
|||
{
|
||||
Url,
|
||||
Port,
|
||||
FanartTv,
|
||||
TheMovieDb
|
||||
}
|
||||
}
|
38
src/Ombi.Store/Entities/Audit.cs
Normal file
38
src/Ombi.Store/Entities/Audit.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
[Table("Audit")]
|
||||
public class Audit : Entity
|
||||
{
|
||||
public DateTime DateTime { get; set; }
|
||||
public string Description { get; set; }
|
||||
public AuditType AuditType { get; set; }
|
||||
public AuditArea AuditArea { get; set; }
|
||||
public string User { get; set; }
|
||||
}
|
||||
|
||||
public enum AuditType
|
||||
{
|
||||
None,
|
||||
Created,
|
||||
Updated,
|
||||
Deleted,
|
||||
Approved,
|
||||
Denied,
|
||||
Success,
|
||||
Fail,
|
||||
Added
|
||||
}
|
||||
|
||||
public enum AuditArea
|
||||
{
|
||||
Authentication,
|
||||
User,
|
||||
TvRequest,
|
||||
MovieRequest,
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ using Ombi.Helpers;
|
|||
namespace Ombi.Store.Migrations
|
||||
{
|
||||
[DbContext(typeof(OmbiContext))]
|
||||
[Migration("20170728131851_Inital")]
|
||||
[Migration("20170801143617_Inital")]
|
||||
partial class Inital
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
|
@ -139,6 +139,26 @@ namespace Ombi.Store.Migrations
|
|||
b.ToTable("ApplicationConfiguration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.Audit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("AuditArea");
|
||||
|
||||
b.Property<int>("AuditType");
|
||||
|
||||
b.Property<DateTime>("DateTime");
|
||||
|
||||
b.Property<string>("Description");
|
||||
|
||||
b.Property<string>("User");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Audit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
|
@ -50,6 +50,23 @@ namespace Ombi.Store.Migrations
|
|||
table.PrimaryKey("PK_ApplicationConfiguration", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Audit",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
AuditArea = table.Column<int>(nullable: false),
|
||||
AuditType = table.Column<int>(nullable: false),
|
||||
DateTime = table.Column<DateTime>(nullable: false),
|
||||
Description = table.Column<string>(nullable: true),
|
||||
User = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Audit", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GlobalSettings",
|
||||
columns: table => new
|
||||
|
@ -545,6 +562,9 @@ namespace Ombi.Store.Migrations
|
|||
migrationBuilder.DropTable(
|
||||
name: "ApplicationConfiguration");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Audit");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "GlobalSettings");
|
||||
|
|
@ -138,6 +138,26 @@ namespace Ombi.Store.Migrations
|
|||
b.ToTable("ApplicationConfiguration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.Audit", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("AuditArea");
|
||||
|
||||
b.Property<int>("AuditType");
|
||||
|
||||
b.Property<DateTime>("DateTime");
|
||||
|
||||
b.Property<string>("Description");
|
||||
|
||||
b.Property<string>("User");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Audit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
|
23
src/Ombi.Store/Repository/ApplicationConfigRepository.cs
Normal file
23
src/Ombi.Store/Repository/ApplicationConfigRepository.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class ApplicationConfigRepository : IApplicationConfigRepository
|
||||
{
|
||||
public ApplicationConfigRepository(IOmbiContext ctx)
|
||||
{
|
||||
Ctx = ctx;
|
||||
}
|
||||
|
||||
private IOmbiContext Ctx { get; }
|
||||
|
||||
public async Task<ApplicationConfiguration> Get(ConfigurationTypes type)
|
||||
{
|
||||
return await Ctx.ApplicationConfigurations.FirstOrDefaultAsync(x => x.Type == type);
|
||||
}
|
||||
}
|
||||
}
|
39
src/Ombi.Store/Repository/AuditRepository.cs
Normal file
39
src/Ombi.Store/Repository/AuditRepository.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class AuditRepository : IAuditRepository
|
||||
{
|
||||
public AuditRepository(IOmbiContext ctx)
|
||||
{
|
||||
Ctx = ctx;
|
||||
}
|
||||
|
||||
private IOmbiContext Ctx { get; }
|
||||
|
||||
|
||||
public async Task Record(AuditType type, AuditArea area, string description)
|
||||
{
|
||||
await Record(type, area, description, string.Empty);
|
||||
}
|
||||
|
||||
public async Task Record(AuditType type, AuditArea area, string description, string user)
|
||||
{
|
||||
await Ctx.Audit.AddAsync(new Audit
|
||||
{
|
||||
User = user,
|
||||
AuditArea = area,
|
||||
AuditType = type,
|
||||
DateTime = DateTime.UtcNow,
|
||||
Description = description
|
||||
});
|
||||
|
||||
await Ctx.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
10
src/Ombi.Store/Repository/IApplicationConfigRepository.cs
Normal file
10
src/Ombi.Store/Repository/IApplicationConfigRepository.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public interface IApplicationConfigRepository
|
||||
{
|
||||
Task<ApplicationConfiguration> Get(ConfigurationTypes type);
|
||||
}
|
||||
}
|
11
src/Ombi.Store/Repository/IAuditRepository.cs
Normal file
11
src/Ombi.Store/Repository/IAuditRepository.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public interface IAuditRepository
|
||||
{
|
||||
Task Record(AuditType type, AuditArea area, string description);
|
||||
Task Record(AuditType type, AuditArea area, string description, string user);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue