From 6544e3f3696e7f621852bcacab72dae37f7649d7 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sat, 6 Jun 2020 16:07:32 +0300 Subject: [PATCH] Add project files. --- Chatbot.Api/Chatbot.Api.csproj | 8 ++++ .../Controllers/WeatherForecastController.cs | 39 +++++++++++++++ Chatbot.Api/Program.cs | 26 ++++++++++ Chatbot.Api/Properties/launchSettings.json | 30 ++++++++++++ Chatbot.Api/Startup.cs | 48 +++++++++++++++++++ Chatbot.Api/WeatherForecast.cs | 15 ++++++ Chatbot.Api/appsettings.Development.json | 9 ++++ Chatbot.Api/appsettings.json | 10 ++++ Chatbot.sln | 25 ++++++++++ 9 files changed, 210 insertions(+) create mode 100644 Chatbot.Api/Chatbot.Api.csproj create mode 100644 Chatbot.Api/Controllers/WeatherForecastController.cs create mode 100644 Chatbot.Api/Program.cs create mode 100644 Chatbot.Api/Properties/launchSettings.json create mode 100644 Chatbot.Api/Startup.cs create mode 100644 Chatbot.Api/WeatherForecast.cs create mode 100644 Chatbot.Api/appsettings.Development.json create mode 100644 Chatbot.Api/appsettings.json create mode 100644 Chatbot.sln diff --git a/Chatbot.Api/Chatbot.Api.csproj b/Chatbot.Api/Chatbot.Api.csproj new file mode 100644 index 0000000..d12c450 --- /dev/null +++ b/Chatbot.Api/Chatbot.Api.csproj @@ -0,0 +1,8 @@ + + + + netcoreapp3.1 + + + + diff --git a/Chatbot.Api/Controllers/WeatherForecastController.cs b/Chatbot.Api/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..f264e78 --- /dev/null +++ b/Chatbot.Api/Controllers/WeatherForecastController.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace Chatbot.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/Chatbot.Api/Program.cs b/Chatbot.Api/Program.cs new file mode 100644 index 0000000..380f5a5 --- /dev/null +++ b/Chatbot.Api/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace Chatbot.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/Chatbot.Api/Properties/launchSettings.json b/Chatbot.Api/Properties/launchSettings.json new file mode 100644 index 0000000..dee1b9c --- /dev/null +++ b/Chatbot.Api/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:54215", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Chatbot.Api": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Chatbot.Api/Startup.cs b/Chatbot.Api/Startup.cs new file mode 100644 index 0000000..82cde74 --- /dev/null +++ b/Chatbot.Api/Startup.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +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; + +namespace Chatbot.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/Chatbot.Api/WeatherForecast.cs b/Chatbot.Api/WeatherForecast.cs new file mode 100644 index 0000000..50db138 --- /dev/null +++ b/Chatbot.Api/WeatherForecast.cs @@ -0,0 +1,15 @@ +using System; + +namespace Chatbot.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/Chatbot.Api/appsettings.Development.json b/Chatbot.Api/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/Chatbot.Api/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/Chatbot.Api/appsettings.json b/Chatbot.Api/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/Chatbot.Api/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/Chatbot.sln b/Chatbot.sln new file mode 100644 index 0000000..decfdec --- /dev/null +++ b/Chatbot.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30002.166 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chatbot.Api", "Chatbot.Api\Chatbot.Api.csproj", "{E317DE66-9513-4666-ADCC-0B7D5B652378}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E317DE66-9513-4666-ADCC-0B7D5B652378}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E317DE66-9513-4666-ADCC-0B7D5B652378}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E317DE66-9513-4666-ADCC-0B7D5B652378}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E317DE66-9513-4666-ADCC-0B7D5B652378}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B43E78A6-ACCC-4A5C-84E2-0B6237C79896} + EndGlobalSection +EndGlobal