From 6f326320cccd7e5fc134b5ab92901b196ba621d3 Mon Sep 17 00:00:00 2001 From: hak8or Date: Sat, 2 Sep 2017 21:04:51 -0400 Subject: [PATCH] Now using single string for DB conns --- YTManager/Startup.cs | 8 +++++--- YTManager/Tasks/FetchVideos.cs | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/YTManager/Startup.cs b/YTManager/Startup.cs index fd20d9b..e586554 100644 --- a/YTManager/Startup.cs +++ b/YTManager/Startup.cs @@ -22,13 +22,15 @@ namespace YTManager { public IConfiguration Configuration { get; } + // String used for connecting to the database server. + public static string dbstr { get; } = "Host=192.168.1.130;Database=postgres;Username=postgres;Password=pass"; + // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); - string constr = "Host=home.hak8or.com;Database=postgres;Username=postgres;Password=mysecretpassword"; - services.AddHangfire(x => x.UsePostgreSqlStorage(constr)); - services.AddDbContext(options => options.UseNpgsql(constr)); + services.AddHangfire(x => x.UsePostgreSqlStorage(dbstr)); + services.AddDbContext(options => options.UseNpgsql(dbstr)); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/YTManager/Tasks/FetchVideos.cs b/YTManager/Tasks/FetchVideos.cs index 34d2be6..1753039 100644 --- a/YTManager/Tasks/FetchVideos.cs +++ b/YTManager/Tasks/FetchVideos.cs @@ -22,8 +22,7 @@ namespace YTManager.Tasks // Get all the channels to update. var ops = new DbContextOptionsBuilder(); - string constr = "Host=home.hak8or.com;Database=postgres;Username=postgres;Password=mysecretpassword"; - ops.UseNpgsql(constr); + ops.UseNpgsql(YTManager.Startup.dbstr); using (var dbcontext = new MediaDB(ops.Options)) { var channels = dbcontext.Channels.ToList();