From 4c566c82f34a5cbc6e075ef000fd4a1246fba9f8 Mon Sep 17 00:00:00 2001 From: Jake Visser Date: Wed, 5 Jul 2017 12:40:57 -0700 Subject: [PATCH] up to scratch --- qcbadge/Controllers/HomeController.cs | 26 ++++----- qcbadge/Startup.cs | 21 ++++++++ qcbadge/Views/Home/About.cshtml | 7 --- qcbadge/Views/Home/Contact.cshtml | 17 ------ qcbadge/Views/Shared/_Layout.cshtml | 76 ++------------------------- qcbadge/qcbadge.csproj | 7 ++- 6 files changed, 41 insertions(+), 113 deletions(-) delete mode 100644 qcbadge/Views/Home/About.cshtml delete mode 100644 qcbadge/Views/Home/Contact.cshtml diff --git a/qcbadge/Controllers/HomeController.cs b/qcbadge/Controllers/HomeController.cs index c8bdd5d..756a9e9 100644 --- a/qcbadge/Controllers/HomeController.cs +++ b/qcbadge/Controllers/HomeController.cs @@ -8,24 +8,20 @@ namespace qcbadge.Controllers { public class HomeController : Controller { - public IActionResult Index() + public IActionResult Index(string s) { - return View(); + + + if ((String.Compare(Startup.scode, s, true) == 0)) + { + ViewData["Message"] = "Code Good"; + return View(); + } + else { return StatusCode(401); } + + } - public IActionResult About() - { - ViewData["Message"] = "Your application description page."; - - return View(); - } - - public IActionResult Contact() - { - ViewData["Message"] = "Your contact page."; - - return View(); - } public IActionResult Error() { diff --git a/qcbadge/Startup.cs b/qcbadge/Startup.cs index faff2a2..b83fedc 100644 --- a/qcbadge/Startup.cs +++ b/qcbadge/Startup.cs @@ -12,6 +12,12 @@ namespace qcbadge { public class Startup { + protected internal static string dbuser; + protected internal static string dbpass; + protected internal static string dburi; + protected internal static string dbname; + protected internal static string scode; + public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() @@ -19,6 +25,12 @@ namespace qcbadge .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); + + if (env.IsDevelopment()) + { + builder.AddUserSecrets(); + } + Configuration = builder.Build(); } @@ -34,6 +46,15 @@ namespace qcbadge // 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) { + + + dbuser = Configuration.GetSection("db")["dbuser"]; + dbpass = Configuration.GetSection("db")["dbpass"]; + dburi = Configuration.GetSection("db")["dburi"]; + dbname = Configuration.GetSection("db")["dbname"]; + scode = Configuration.GetSection("s")["code"]; + + loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); diff --git a/qcbadge/Views/Home/About.cshtml b/qcbadge/Views/Home/About.cshtml deleted file mode 100644 index 50476d1..0000000 --- a/qcbadge/Views/Home/About.cshtml +++ /dev/null @@ -1,7 +0,0 @@ -@{ - ViewData["Title"] = "About"; -} -

@ViewData["Title"].

-

@ViewData["Message"]

- -

Use this area to provide additional information.

diff --git a/qcbadge/Views/Home/Contact.cshtml b/qcbadge/Views/Home/Contact.cshtml deleted file mode 100644 index 15c12c6..0000000 --- a/qcbadge/Views/Home/Contact.cshtml +++ /dev/null @@ -1,17 +0,0 @@ -@{ - ViewData["Title"] = "Contact"; -} -

@ViewData["Title"].

-

@ViewData["Message"]

- -
- One Microsoft Way
- Redmond, WA 98052-6399
- P: - 425.555.0100 -
- -
- Support: Support@example.com
- Marketing: Marketing@example.com -
diff --git a/qcbadge/Views/Shared/_Layout.cshtml b/qcbadge/Views/Shared/_Layout.cshtml index b29b508..d324da6 100644 --- a/qcbadge/Views/Shared/_Layout.cshtml +++ b/qcbadge/Views/Shared/_Layout.cshtml @@ -1,73 +1,5 @@ -@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet - - - - - - @ViewData["Title"] - qcbadge +@{ + ViewData["Title"] = "Home Page"; +} - - - - - - - - - @Html.Raw(JavaScriptSnippet.FullScript) - - - -
- @RenderBody() -
-
-

© 2017 - qcbadge

-
-
- - - - - - - - - - - - - @RenderSection("Scripts", required: false) - - +

@ViewData["Message"]

diff --git a/qcbadge/qcbadge.csproj b/qcbadge/qcbadge.csproj index 39fcf83..ee12b69 100644 --- a/qcbadge/qcbadge.csproj +++ b/qcbadge/qcbadge.csproj @@ -1,4 +1,4 @@ - + netcoreapp1.1 @@ -6,14 +6,17 @@ $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; + 96719452-ec83-4ff8-b4ca-8e67a417ce96 - + + +