From 098bfa5cd15cef0985154645d690d08e4557729f Mon Sep 17 00:00:00 2001 From: Chika Date: Mon, 12 Oct 2020 16:21:27 +0300 Subject: [PATCH] structured solution --- .../.idea/contentModel.xml | 57 +++++++- .../.idea/workspace.xml | 129 ++++++++++++++++++ .../EvoCalculator.Core.Calculation.csproj | 7 + .../EvoCalculator.Core.Models.csproj | 13 ++ .../Weather/Interfaces/IWeatherForecast.cs | 12 ++ .../Weather}/WeatherForecast.cs | 5 +- .../EvoCalculator.Core.Tests.csproj | 16 +++ EvoCalculator.Core.sln | 18 +++ .../{ => v1}/WeatherForecastController.cs | 9 +- EvoCalculator.Core/EvoCalculator.Core.csproj | 8 ++ EvoCalculator.Core/Startup.cs | 12 +- 11 files changed, 272 insertions(+), 14 deletions(-) create mode 100644 EvoCalculator.Core.Calculation/EvoCalculator.Core.Calculation.csproj create mode 100644 EvoCalculator.Core.Models/EvoCalculator.Core.Models.csproj create mode 100644 EvoCalculator.Core.Models/Weather/Interfaces/IWeatherForecast.cs rename {EvoCalculator.Core => EvoCalculator.Core.Models/Weather}/WeatherForecast.cs (61%) create mode 100644 EvoCalculator.Core.Tests/EvoCalculator.Core.Tests.csproj rename EvoCalculator.Core/Controllers/{ => v1}/WeatherForecastController.cs (86%) diff --git a/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml b/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml index edccf9a..8a34018 100644 --- a/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml +++ b/.idea/.idea.EvoCalculator.Core/.idea/contentModel.xml @@ -1,6 +1,14 @@ + + + + + + + + @@ -9,7 +17,9 @@ - + + + @@ -24,9 +34,52 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml b/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml index b2b7f3e..6d087df 100644 --- a/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml +++ b/.idea/.idea.EvoCalculator.Core/.idea/workspace.xml @@ -1,5 +1,68 @@ + + EvoCalculator.Core/EvoCalculator.Core.csproj + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1602504351800 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EvoCalculator.Core.Calculation/EvoCalculator.Core.Calculation.csproj b/EvoCalculator.Core.Calculation/EvoCalculator.Core.Calculation.csproj new file mode 100644 index 0000000..8642d92 --- /dev/null +++ b/EvoCalculator.Core.Calculation/EvoCalculator.Core.Calculation.csproj @@ -0,0 +1,7 @@ + + + + netcoreapp3.1 + + + diff --git a/EvoCalculator.Core.Models/EvoCalculator.Core.Models.csproj b/EvoCalculator.Core.Models/EvoCalculator.Core.Models.csproj new file mode 100644 index 0000000..9c38250 --- /dev/null +++ b/EvoCalculator.Core.Models/EvoCalculator.Core.Models.csproj @@ -0,0 +1,13 @@ + + + + netcoreapp3.1 + + + + + + + + + diff --git a/EvoCalculator.Core.Models/Weather/Interfaces/IWeatherForecast.cs b/EvoCalculator.Core.Models/Weather/Interfaces/IWeatherForecast.cs new file mode 100644 index 0000000..228f14b --- /dev/null +++ b/EvoCalculator.Core.Models/Weather/Interfaces/IWeatherForecast.cs @@ -0,0 +1,12 @@ +using System; + +namespace EvoCalculator.Core.Models.Weather.Interfaces +{ + public interface IWeatherForecast + { + public DateTime Date { get; set; } + public int TemperatureC { get; set; } + public int TemperatureF { get; } + public string Summary { get; set; } + } +} \ No newline at end of file diff --git a/EvoCalculator.Core/WeatherForecast.cs b/EvoCalculator.Core.Models/Weather/WeatherForecast.cs similarity index 61% rename from EvoCalculator.Core/WeatherForecast.cs rename to EvoCalculator.Core.Models/Weather/WeatherForecast.cs index 0f83109..6fcaaae 100644 --- a/EvoCalculator.Core/WeatherForecast.cs +++ b/EvoCalculator.Core.Models/Weather/WeatherForecast.cs @@ -1,8 +1,9 @@ using System; +using EvoCalculator.Core.Models.Weather.Interfaces; -namespace EvoCalculator.Core +namespace EvoCalculator.Core.Models.Weather { - public class WeatherForecast + public class WeatherForecast:IWeatherForecast { public DateTime Date { get; set; } diff --git a/EvoCalculator.Core.Tests/EvoCalculator.Core.Tests.csproj b/EvoCalculator.Core.Tests/EvoCalculator.Core.Tests.csproj new file mode 100644 index 0000000..5d0a1da --- /dev/null +++ b/EvoCalculator.Core.Tests/EvoCalculator.Core.Tests.csproj @@ -0,0 +1,16 @@ + + + + netcoreapp3.1 + + false + + + + + + + + + + diff --git a/EvoCalculator.Core.sln b/EvoCalculator.Core.sln index 4255010..907c2c6 100644 --- a/EvoCalculator.Core.sln +++ b/EvoCalculator.Core.sln @@ -2,6 +2,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvoCalculator.Core", "EvoCalculator.Core\EvoCalculator.Core.csproj", "{D1AA257A-BA2B-44FD-85E8-F4813B1A453C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvoCalculator.Core.Calculation", "EvoCalculator.Core.Calculation\EvoCalculator.Core.Calculation.csproj", "{07646F9C-F060-4EF5-AEA6-CA88D6CD752D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvoCalculator.Core.Tests", "EvoCalculator.Core.Tests\EvoCalculator.Core.Tests.csproj", "{97CF5335-8641-4A4F-A6CD-641BF8655B53}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvoCalculator.Core.Models", "EvoCalculator.Core.Models\EvoCalculator.Core.Models.csproj", "{768ED2B0-5BCE-484F-873B-ADF4DC22687F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -12,5 +18,17 @@ Global {D1AA257A-BA2B-44FD-85E8-F4813B1A453C}.Debug|Any CPU.Build.0 = Debug|Any CPU {D1AA257A-BA2B-44FD-85E8-F4813B1A453C}.Release|Any CPU.ActiveCfg = Release|Any CPU {D1AA257A-BA2B-44FD-85E8-F4813B1A453C}.Release|Any CPU.Build.0 = Release|Any CPU + {07646F9C-F060-4EF5-AEA6-CA88D6CD752D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {07646F9C-F060-4EF5-AEA6-CA88D6CD752D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {07646F9C-F060-4EF5-AEA6-CA88D6CD752D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {07646F9C-F060-4EF5-AEA6-CA88D6CD752D}.Release|Any CPU.Build.0 = Release|Any CPU + {97CF5335-8641-4A4F-A6CD-641BF8655B53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97CF5335-8641-4A4F-A6CD-641BF8655B53}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97CF5335-8641-4A4F-A6CD-641BF8655B53}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97CF5335-8641-4A4F-A6CD-641BF8655B53}.Release|Any CPU.Build.0 = Release|Any CPU + {768ED2B0-5BCE-484F-873B-ADF4DC22687F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {768ED2B0-5BCE-484F-873B-ADF4DC22687F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {768ED2B0-5BCE-484F-873B-ADF4DC22687F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {768ED2B0-5BCE-484F-873B-ADF4DC22687F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/EvoCalculator.Core/Controllers/WeatherForecastController.cs b/EvoCalculator.Core/Controllers/v1/WeatherForecastController.cs similarity index 86% rename from EvoCalculator.Core/Controllers/WeatherForecastController.cs rename to EvoCalculator.Core/Controllers/v1/WeatherForecastController.cs index 6605452..9987642 100644 --- a/EvoCalculator.Core/Controllers/WeatherForecastController.cs +++ b/EvoCalculator.Core/Controllers/v1/WeatherForecastController.cs @@ -1,14 +1,15 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; +using EvoCalculator.Core.Models.Weather; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; -namespace EvoCalculator.Core.Controllers +namespace EvoCalculator.Core.Controllers.V1 { [ApiController] - [Route("[controller]")] + [ApiVersion("1.0")] + [Route("api/v{version:apiVersion}/[controller]")] public class WeatherForecastController : ControllerBase { private static readonly string[] Summaries = new[] @@ -22,7 +23,7 @@ namespace EvoCalculator.Core.Controllers { _logger = logger; } - + [HttpGet] public IEnumerable Get() { diff --git a/EvoCalculator.Core/EvoCalculator.Core.csproj b/EvoCalculator.Core/EvoCalculator.Core.csproj index 68ded6d..388bcc8 100644 --- a/EvoCalculator.Core/EvoCalculator.Core.csproj +++ b/EvoCalculator.Core/EvoCalculator.Core.csproj @@ -4,5 +4,13 @@ netcoreapp3.1 + + + + + + + + diff --git a/EvoCalculator.Core/Startup.cs b/EvoCalculator.Core/Startup.cs index d2cbbaa..dafc37b 100644 --- a/EvoCalculator.Core/Startup.cs +++ b/EvoCalculator.Core/Startup.cs @@ -1,15 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; namespace EvoCalculator.Core { @@ -26,6 +20,12 @@ namespace EvoCalculator.Core public void ConfigureServices(IServiceCollection services) { services.AddControllers(); + + services.AddApiVersioning(opt => { + opt.DefaultApiVersion = new ApiVersion(1, 0); + opt.AssumeDefaultVersionWhenUnspecified = true; + opt.ReportApiVersions = true; + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.