From 0e6a1707f4943dbc23ded734a175304aed546505 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Wed, 13 Sep 2017 09:20:26 +0100 Subject: [PATCH] #1486 --- build.cake | 26 +++++++++---------- src/Ombi.Store/Ombi.Store.csproj | 1 + src/Ombi/.gitignore | 1 + .../ApiV1Attribute.cs | 0 .../Controllers/External/EmbyController.cs | 1 + .../Controllers/External/PlexController.cs | 1 + .../Controllers/External/RadarrController.cs | 1 + .../Controllers/External/SonarrController.cs | 1 + .../Controllers/External/TesterController.cs | 1 + src/Ombi/Controllers/IdentityController.cs | 1 + src/Ombi/Controllers/ImagesController.cs | 1 + src/Ombi/Controllers/LandingPageController.cs | 1 + src/Ombi/Controllers/LoggingController.cs | 1 + src/Ombi/Controllers/RequestController.cs | 1 + src/Ombi/Controllers/SearchController.cs | 1 + src/Ombi/Controllers/SettingsController.cs | 1 + src/Ombi/Controllers/StatusController.cs | 1 + src/Ombi/Controllers/TokenController.cs | 1 + src/Ombi/Ombi.csproj | 4 +++ src/Ombi/Startup.cs | 16 ++++++++---- 20 files changed, 44 insertions(+), 18 deletions(-) rename src/Ombi/{Controllers => Attributes}/ApiV1Attribute.cs (100%) diff --git a/build.cake b/build.cake index 183319080..17130e9dd 100644 --- a/build.cake +++ b/build.cake @@ -28,19 +28,19 @@ GitVersion versionInfo = null; var buildSettings = new DotNetCoreBuildSettings { - Framework = "netcoreapp1.1", + Framework = "netcoreapp2.0", Configuration = "Release", OutputDirectory = Directory(buildDir), }; var publishSettings = new DotNetCorePublishSettings { - Framework = "netcoreapp1.1", + Framework = "netcoreapp2.0", Configuration = "Release", OutputDirectory = Directory(buildDir), }; -var artifactsFolder = buildDir + "/netcoreapp1.1/"; +var artifactsFolder = buildDir + "/netcoreapp2.0/"; var windowsArtifactsFolder = artifactsFolder + "win10-x64/published"; var osxArtifactsFolder = artifactsFolder + "osx.10.12-x64/published"; var ubuntuArtifactsFolder = artifactsFolder + "ubuntu.16.04-x64/published"; @@ -151,10 +151,10 @@ Task("Publish-Windows") .Does(() => { publishSettings.Runtime = "win10-x64"; - publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp1.1/win10-x64/published"); + publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp2.0/win10-x64/published"); DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings); - CopyFile(buildDir + "/netcoreapp1.1/win10-x64/Swagger.xml", buildDir + "/netcoreapp1.1/win10-x64/published/Swagger.xml"); + CopyFile(buildDir + "/netcoreapp2.0/win10-x64/Swagger.xml", buildDir + "/netcoreapp2.0/win10-x64/published/Swagger.xml"); DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings); }); @@ -162,10 +162,10 @@ Task("Publish-OSX") .Does(() => { publishSettings.Runtime = "osx.10.12-x64"; - publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp1.1/osx.10.12-x64/published"); + publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp2.0/osx.10.12-x64/published"); DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings); - CopyFile(buildDir + "/netcoreapp1.1/osx.10.12-x64/Swagger.xml", buildDir + "/netcoreapp1.1/osx.10.12-x64/published/Swagger.xml"); + CopyFile(buildDir + "/netcoreapp2.0/osx.10.12-x64/Swagger.xml", buildDir + "/netcoreapp2.0/osx.10.12-x64/published/Swagger.xml"); DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings); }); @@ -173,30 +173,30 @@ Task("Publish-Ubuntu") .Does(() => { publishSettings.Runtime = "ubuntu.16.04-x64"; - publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp1.1/ubuntu.16.04-x64/published"); + publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp2.0/ubuntu.16.04-x64/published"); DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings); - CopyFile(buildDir + "/netcoreapp1.1/ubuntu.16.04-x64/Swagger.xml", buildDir + "/netcoreapp1.1/ubuntu.16.04-x64/published/Swagger.xml"); + CopyFile(buildDir + "/netcoreapp2.0/ubuntu.16.04-x64/Swagger.xml", buildDir + "/netcoreapp2.0/ubuntu.16.04-x64/published/Swagger.xml"); DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings); }); Task("Publish-Debian") .Does(() => { publishSettings.Runtime = "debian.8-x64"; - publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp1.1/debian.8-x64/published"); + publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp2.0/debian.8-x64/published"); DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings); - CopyFile(buildDir + "/netcoreapp1.1/debian.8-x64/Swagger.xml", buildDir + "/netcoreapp1.1/debian.8-x64/published/Swagger.xml"); + CopyFile(buildDir + "/netcoreapp2.0/debian.8-x64/Swagger.xml", buildDir + "/netcoreapp2.0/debian.8-x64/published/Swagger.xml"); DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings); }); Task("Publish-Centos") .Does(() => { publishSettings.Runtime = "centos.7-x64"; - publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp1.1/centos.7-x64/published"); + publishSettings.OutputDirectory = Directory(buildDir) + Directory("netcoreapp2.0/centos.7-x64/published"); DotNetCorePublish("./src/Ombi/Ombi.csproj", publishSettings); - CopyFile(buildDir + "/netcoreapp1.1/centos.7-x64/Swagger.xml", buildDir + "/netcoreapp1.1/centos.7-x64/published/Swagger.xml"); + CopyFile(buildDir + "/netcoreapp2.0/centos.7-x64/Swagger.xml", buildDir + "/netcoreapp2.0/centos.7-x64/published/Swagger.xml"); DotNetCorePublish("./src/Ombi.Updater/Ombi.Updater.csproj", publishSettings); }); diff --git a/src/Ombi.Store/Ombi.Store.csproj b/src/Ombi.Store/Ombi.Store.csproj index 0d8b793d5..2dcd76cc3 100644 --- a/src/Ombi.Store/Ombi.Store.csproj +++ b/src/Ombi.Store/Ombi.Store.csproj @@ -6,6 +6,7 @@ 3.0.0.0 + true diff --git a/src/Ombi/.gitignore b/src/Ombi/.gitignore index ae9772467..b370cf723 100644 --- a/src/Ombi/.gitignore +++ b/src/Ombi/.gitignore @@ -20,3 +20,4 @@ testem.log #/typings /systemjs.config.js* /Logs/** +**.db diff --git a/src/Ombi/Controllers/ApiV1Attribute.cs b/src/Ombi/Attributes/ApiV1Attribute.cs similarity index 100% rename from src/Ombi/Controllers/ApiV1Attribute.cs rename to src/Ombi/Attributes/ApiV1Attribute.cs diff --git a/src/Ombi/Controllers/External/EmbyController.cs b/src/Ombi/Controllers/External/EmbyController.cs index 1ae68eb31..9723f3330 100644 --- a/src/Ombi/Controllers/External/EmbyController.cs +++ b/src/Ombi/Controllers/External/EmbyController.cs @@ -14,6 +14,7 @@ namespace Ombi.Controllers.External /// [Admin] [ApiV1] + [Produces("application/json")] public class EmbyController : Controller { /// diff --git a/src/Ombi/Controllers/External/PlexController.cs b/src/Ombi/Controllers/External/PlexController.cs index ec62d36f4..b9d0446f6 100644 --- a/src/Ombi/Controllers/External/PlexController.cs +++ b/src/Ombi/Controllers/External/PlexController.cs @@ -15,6 +15,7 @@ namespace Ombi.Controllers.External { [Admin] [ApiV1] + [Produces("application/json")] public class PlexController : Controller { public PlexController(IPlexApi plexApi, ISettingsService plexSettings) diff --git a/src/Ombi/Controllers/External/RadarrController.cs b/src/Ombi/Controllers/External/RadarrController.cs index 849e6bdb3..6e4884112 100644 --- a/src/Ombi/Controllers/External/RadarrController.cs +++ b/src/Ombi/Controllers/External/RadarrController.cs @@ -11,6 +11,7 @@ namespace Ombi.Controllers.External { [Admin] [ApiV1] + [Produces("application/json")] public class RadarrController : Controller { public RadarrController(IRadarrApi radarr, ISettingsService settings) diff --git a/src/Ombi/Controllers/External/SonarrController.cs b/src/Ombi/Controllers/External/SonarrController.cs index 6d2043a14..765649e68 100644 --- a/src/Ombi/Controllers/External/SonarrController.cs +++ b/src/Ombi/Controllers/External/SonarrController.cs @@ -12,6 +12,7 @@ namespace Ombi.Controllers.External { [Admin] [ApiV1] + [Produces("application/json")] public class SonarrController : Controller { public SonarrController(ISonarrApi sonarr, ISettingsService settings) diff --git a/src/Ombi/Controllers/External/TesterController.cs b/src/Ombi/Controllers/External/TesterController.cs index 2bb3b710a..ac0df1914 100644 --- a/src/Ombi/Controllers/External/TesterController.cs +++ b/src/Ombi/Controllers/External/TesterController.cs @@ -25,6 +25,7 @@ namespace Ombi.Controllers.External /// [Admin] [ApiV1] + [Produces("application/json")] public class TesterController : Controller { /// diff --git a/src/Ombi/Controllers/IdentityController.cs b/src/Ombi/Controllers/IdentityController.cs index fc329ecf4..26fd93714 100644 --- a/src/Ombi/Controllers/IdentityController.cs +++ b/src/Ombi/Controllers/IdentityController.cs @@ -35,6 +35,7 @@ namespace Ombi.Controllers /// [PowerUser] [ApiV1] + [Produces("application/json")] public class IdentityController : Controller { public IdentityController(UserManager user, IMapper mapper, RoleManager rm, IEmailProvider prov, diff --git a/src/Ombi/Controllers/ImagesController.cs b/src/Ombi/Controllers/ImagesController.cs index f1e35ae9f..7e698eb97 100644 --- a/src/Ombi/Controllers/ImagesController.cs +++ b/src/Ombi/Controllers/ImagesController.cs @@ -11,6 +11,7 @@ using Ombi.Config; namespace Ombi.Controllers { [ApiV1] + [Produces("application/json")] public class ImagesController : Controller { public ImagesController(IFanartTvApi api, IApplicationConfigRepository config, IOptions options) diff --git a/src/Ombi/Controllers/LandingPageController.cs b/src/Ombi/Controllers/LandingPageController.cs index c913d2498..0582a931d 100644 --- a/src/Ombi/Controllers/LandingPageController.cs +++ b/src/Ombi/Controllers/LandingPageController.cs @@ -13,6 +13,7 @@ namespace Ombi.Controllers { [ApiV1] [AllowAnonymous] + [Produces("application/json")] public class LandingPageController { public LandingPageController(ISettingsService plex, ISettingsService emby, diff --git a/src/Ombi/Controllers/LoggingController.cs b/src/Ombi/Controllers/LoggingController.cs index dd12ae1a4..a61b6c144 100644 --- a/src/Ombi/Controllers/LoggingController.cs +++ b/src/Ombi/Controllers/LoggingController.cs @@ -8,6 +8,7 @@ namespace Ombi.Controllers { [Authorize] [ApiV1] + [Produces("application/json")] public class LoggingController : Controller { public LoggingController(ILogger logger) diff --git a/src/Ombi/Controllers/RequestController.cs b/src/Ombi/Controllers/RequestController.cs index 86602c01a..fb9a40f6e 100644 --- a/src/Ombi/Controllers/RequestController.cs +++ b/src/Ombi/Controllers/RequestController.cs @@ -13,6 +13,7 @@ namespace Ombi.Controllers { [Authorize] [ApiV1] + [Produces("application/json")] public class RequestController : Controller { public RequestController(IMovieRequestEngine engine, ITvRequestEngine tvRequestEngine) diff --git a/src/Ombi/Controllers/SearchController.cs b/src/Ombi/Controllers/SearchController.cs index 7150a423b..dd31f8392 100644 --- a/src/Ombi/Controllers/SearchController.cs +++ b/src/Ombi/Controllers/SearchController.cs @@ -15,6 +15,7 @@ namespace Ombi.Controllers { [Authorize] [ApiV1] + [Produces("application/json")] public class SearchController : Controller { public SearchController(IMovieEngine movie, ITvSearchEngine tvEngine, ILogger logger) diff --git a/src/Ombi/Controllers/SettingsController.cs b/src/Ombi/Controllers/SettingsController.cs index 69ecf85a4..c4b6a9bb6 100644 --- a/src/Ombi/Controllers/SettingsController.cs +++ b/src/Ombi/Controllers/SettingsController.cs @@ -30,6 +30,7 @@ namespace Ombi.Controllers /// [Admin] [ApiV1] + [Produces("application/json")] public class SettingsController : Controller { /// diff --git a/src/Ombi/Controllers/StatusController.cs b/src/Ombi/Controllers/StatusController.cs index 6a044cccb..242a76019 100644 --- a/src/Ombi/Controllers/StatusController.cs +++ b/src/Ombi/Controllers/StatusController.cs @@ -37,6 +37,7 @@ using Ombi.Settings.Settings.Models; namespace Ombi.Controllers { [ApiV1] + [Produces("application/json")] public class StatusController : Controller { public StatusController(ISettingsService ombi) diff --git a/src/Ombi/Controllers/TokenController.cs b/src/Ombi/Controllers/TokenController.cs index fc7af8ae8..abe505ddd 100644 --- a/src/Ombi/Controllers/TokenController.cs +++ b/src/Ombi/Controllers/TokenController.cs @@ -18,6 +18,7 @@ using Ombi.Store.Repository; namespace Ombi.Controllers { [ApiV1] + [Produces("application/json")] public class TokenController { public TokenController(UserManager um, IOptions ta, diff --git a/src/Ombi/Ombi.csproj b/src/Ombi/Ombi.csproj index 0e855d934..28213636b 100644 --- a/src/Ombi/Ombi.csproj +++ b/src/Ombi/Ombi.csproj @@ -40,6 +40,10 @@ + + + + diff --git a/src/Ombi/Startup.cs b/src/Ombi/Startup.cs index 44578c292..695b60bc5 100644 --- a/src/Ombi/Startup.cs +++ b/src/Ombi/Startup.cs @@ -71,11 +71,10 @@ namespace Ombi public IConfigurationRoot Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) + public IServiceProvider ConfigureServices(IServiceCollection services) { // Add framework services. - services.AddDbContext(options => - options.UseSqlite("Data Source=Ombi.db")); + services.AddDbContext(); services.AddIdentity() .AddEntityFrameworkStores() @@ -179,13 +178,20 @@ namespace Ombi x.Audience = "Ombi"; x.TokenValidationParameters = tokenValidationParameters; }); + + // Build the intermediate service provider + var serviceProvider = services.BuildServiceProvider(); + + //return the provider + return serviceProvider; } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IMemoryCache cache) + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, + IMemoryCache cache, IServiceProvider serviceProvider) { - var ctx = (IOmbiContext)app.ApplicationServices.GetService(typeof(IOmbiContext)); + var ctx = serviceProvider.GetService();