Permalink
Browse files

Added UserSecrets

  • Loading branch information...
Jaryn91 committed Apr 26, 2018
1 parent c96c022 commit 1f94a8d609785a50c56e5aaae3533a979674d5b2
@@ -14,12 +14,15 @@ namespace Musiction.API.BusinessLogic
public class PptxToJpgConverter
{
private Uri baseUri = new Uri("https://sandbox.zamzar.com/v1/");
private string _apiKey = Startup.Configuration["zamzarKey"];
private string _apiKey;
private IFileAndFolderPathsCreator _fileAndFolderPath;
public PptxToJpgConverter(IFileAndFolderPathsCreator fileAndFolderPath)
{
_fileAndFolderPath = fileAndFolderPath;
var propName = Startup.Configuration["environment"] + "ZamzarKey";
_apiKey = Startup.Configuration[propName];
}
public string Convert(string sourceFile)
{
@@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<UserSecretsId>79c7fe53-1b92-4bc2-ad7e-318e817f92c9</UserSecretsId>
</PropertyGroup>
<ItemGroup>
@@ -20,6 +21,7 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Cors" Version="2.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.1" />
@@ -1,28 +1,38 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using System.Collections.Generic;
namespace Musiction.API
{
public class Program
{
private static readonly Dictionary<string, string> defaults =
new Dictionary<string, string> { {
WebHostDefaults.EnvironmentKey, "development"
} };
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
public static IWebHost BuildWebHost(string[] args)
{
var element = WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((webHostBuilderContext, configurationbuilder) =>
{
var environment = webHostBuilderContext.HostingEnvironment;
configurationbuilder
.AddJsonFile("appSettings.json", optional: false);
configurationbuilder.AddEnvironmentVariables();
configurationbuilder.AddJsonFile("appSettings.json", optional: false)
.AddInMemoryCollection(defaults)
.AddEnvironmentVariables("ASPNETCORE_")
.AddCommandLine(args)
.AddUserSecrets<Startup>();
})
.UseStartup<Startup>()
.Build();
return element;
}
}
}
@@ -48,7 +48,9 @@ public void ConfigureServices(IServiceCollection services)
services.AddTransient<IMailService, LocalMailService>();
var connectionString = Startup.Configuration["connectionStrings"];
var propName = Startup.Configuration["environment"] + "ConnectionString";
var connectionString = Startup.Configuration[propName];
services.AddDbContext<SongContext>(o => o.UseMySql(connectionString));
services.AddScoped<ISongRepository, SongRepository>();
@@ -64,8 +66,6 @@ public void ConfigureServices(IServiceCollection services)
loggerFactory.AddDebug();
loggerFactory.AddNLog();
songContext.EnsureSeedDataForContext();
if (env.IsDevelopment())

0 comments on commit 1f94a8d

Please sign in to comment.