From e04d7961a5bd9b5b9f2dbc690e1b53099499fd9a Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sat, 19 Dec 2020 18:17:24 +0200 Subject: [PATCH] Add project files. --- .../Controllers/WeatherForecastController.cs | 39 +++++++++++++++ IdentityServer.Api/IdentityServer.Api.csproj | 8 ++++ IdentityServer.Api/Program.cs | 26 ++++++++++ .../Properties/launchSettings.json | 30 ++++++++++++ IdentityServer.Api/Startup.cs | 48 +++++++++++++++++++ IdentityServer.Api/WeatherForecast.cs | 15 ++++++ .../appsettings.Development.json | 9 ++++ IdentityServer.Api/appsettings.json | 10 ++++ IdentityServer.sln | 30 ++++++++++++ 9 files changed, 215 insertions(+) create mode 100644 IdentityServer.Api/Controllers/WeatherForecastController.cs create mode 100644 IdentityServer.Api/IdentityServer.Api.csproj create mode 100644 IdentityServer.Api/Program.cs create mode 100644 IdentityServer.Api/Properties/launchSettings.json create mode 100644 IdentityServer.Api/Startup.cs create mode 100644 IdentityServer.Api/WeatherForecast.cs create mode 100644 IdentityServer.Api/appsettings.Development.json create mode 100644 IdentityServer.Api/appsettings.json create mode 100644 IdentityServer.sln diff --git a/IdentityServer.Api/Controllers/WeatherForecastController.cs b/IdentityServer.Api/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..4c4f395 --- /dev/null +++ b/IdentityServer.Api/Controllers/WeatherForecastController.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace IdentityServer.Api.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet] + public IEnumerable Get() + { + var rng = new Random(); + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = rng.Next(-20, 55), + Summary = Summaries[rng.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/IdentityServer.Api/IdentityServer.Api.csproj b/IdentityServer.Api/IdentityServer.Api.csproj new file mode 100644 index 0000000..d12c450 --- /dev/null +++ b/IdentityServer.Api/IdentityServer.Api.csproj @@ -0,0 +1,8 @@ + + + + netcoreapp3.1 + + + + diff --git a/IdentityServer.Api/Program.cs b/IdentityServer.Api/Program.cs new file mode 100644 index 0000000..5a4a626 --- /dev/null +++ b/IdentityServer.Api/Program.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace IdentityServer.Api +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/IdentityServer.Api/Properties/launchSettings.json b/IdentityServer.Api/Properties/launchSettings.json new file mode 100644 index 0000000..aabc163 --- /dev/null +++ b/IdentityServer.Api/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:53730", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IdentityServer.Api": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/IdentityServer.Api/Startup.cs b/IdentityServer.Api/Startup.cs new file mode 100644 index 0000000..009c8e3 --- /dev/null +++ b/IdentityServer.Api/Startup.cs @@ -0,0 +1,48 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace IdentityServer.Api +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/IdentityServer.Api/WeatherForecast.cs b/IdentityServer.Api/WeatherForecast.cs new file mode 100644 index 0000000..f28828d --- /dev/null +++ b/IdentityServer.Api/WeatherForecast.cs @@ -0,0 +1,15 @@ +using System; + +namespace IdentityServer.Api +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string Summary { get; set; } + } +} diff --git a/IdentityServer.Api/appsettings.Development.json b/IdentityServer.Api/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/IdentityServer.Api/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/IdentityServer.Api/appsettings.json b/IdentityServer.Api/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/IdentityServer.Api/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/IdentityServer.sln b/IdentityServer.sln new file mode 100644 index 0000000..831f065 --- /dev/null +++ b/IdentityServer.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5A8FF505-3E4D-4258-BC3E-CACD74A7B98C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer.Api", "IdentityServer.Api\IdentityServer.Api.csproj", "{2F84E560-EEC0-4511-B8D9-2C35C226B688}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2F84E560-EEC0-4511-B8D9-2C35C226B688}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F84E560-EEC0-4511-B8D9-2C35C226B688}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F84E560-EEC0-4511-B8D9-2C35C226B688}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F84E560-EEC0-4511-B8D9-2C35C226B688}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {2F84E560-EEC0-4511-B8D9-2C35C226B688} = {5A8FF505-3E4D-4258-BC3E-CACD74A7B98C} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E93DC46D-9C55-4A05-B299-497CDD90747E} + EndGlobalSection +EndGlobal