From 3d034f3d4d18e782ff9ba6e838b3b448fc5dd4d9 Mon Sep 17 00:00:00 2001 From: Daniel Gerst Date: Mon, 18 Dec 2023 12:10:34 +0100 Subject: [PATCH] Fix exapmples --- .../Extensions/IConfigurationExtensions.cs | 4 ++-- .../WebApiConfiguration.OpenId.cs | 2 +- .../WebApiConfiguration.Swagger.cs | 2 +- .../Configurations/WebApiConfiguration.cs | 2 +- .../EntityNotFoundExceptionTransformation.cs | 16 ++++++++------ .../ValidationExceptionTransformation.cs | 10 ++++----- .../Common/StartupTasks/ExampleStartupTask.cs | 2 +- .../Controllers/1.0/ExampleController.cs | 2 +- .../Controllers/1.1/ExampleController.cs | 4 ++-- .../GerstITS.Examples.Api.csproj | 21 ++++++++++++------- GerstITS.Examples.Api/Module.Mvc.cs | 20 ------------------ GerstITS.Examples.Api/Module.cs | 1 - GerstITS.Examples.Api/Program.cs | 2 +- .../Properties/launchSettings.json | 8 +++++++ GerstITS.Examples.Api/Startup.cs | 2 +- ...erstITS.Examples.Jobs.SayHelloWorld.csproj | 2 +- .../Jobs/SayHelloWorldJob.cs | 1 - .../GerstITS.Examples.Logic.csproj | 6 +++--- 18 files changed, 51 insertions(+), 56 deletions(-) delete mode 100644 GerstITS.Examples.Api/Module.Mvc.cs diff --git a/GerstITS.Examples.Api/Common/Configurations/Extensions/IConfigurationExtensions.cs b/GerstITS.Examples.Api/Common/Configurations/Extensions/IConfigurationExtensions.cs index 8200f19..e60a637 100644 --- a/GerstITS.Examples.Api/Common/Configurations/Extensions/IConfigurationExtensions.cs +++ b/GerstITS.Examples.Api/Common/Configurations/Extensions/IConfigurationExtensions.cs @@ -14,8 +14,8 @@ public static class IConfigurationExtensions ThrowsAnExceptionIfTypeIsNotAnEnumeration(); return (TEnum)(object)(configuration.GetSection(key)? - .Get() ?? Enumerable.Empty()) - .Sum(i => (int)(object)i); + .Get() ?? Enumerable.Empty()) + .Sum(i => (int)(object)i); } private static void ThrowsAnExceptionIfTypeIsNotAnEnumeration() where TEnum : struct, IConvertible diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.cs index 8fdfebc..acac430 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.OpenId.cs @@ -9,7 +9,7 @@ internal class OpenIdConfiguration : IOpenIdConfiguration #region Constructors public OpenIdConfiguration(string parentPrefix, - Microsoft.Extensions.Configuration.IConfiguration configuration) + Microsoft.Extensions.Configuration.IConfiguration configuration) { var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.cs index da44c8b..e38041b 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.Swagger.cs @@ -11,7 +11,7 @@ internal sealed class SwaggerConfiguration : ISwaggerConfiguration #region Constructors public SwaggerConfiguration(string parentPrefix, - Microsoft.Extensions.Configuration.IConfiguration configuration) + Microsoft.Extensions.Configuration.IConfiguration configuration) { var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}"; diff --git a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.cs b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.cs index 1b98792..1707103 100644 --- a/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.cs +++ b/GerstITS.Examples.Api/Common/Configurations/WebApiConfiguration.cs @@ -24,7 +24,7 @@ internal sealed class WebApiConfiguration : IConfiguration var prefix = this.ToConfigurationPrefix(); EntityFrameworkMigration = new EntityFrameworkMigrationConfiguration(prefix, configuration); - OpenId = new OpenIdConfiguration(prefix, configuration); + //OpenId = new OpenIdConfiguration(prefix, configuration); Server = new ServerConfiguration(prefix, configuration); Swagger = new SwaggerConfiguration(prefix, configuration); } diff --git a/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/EntityNotFoundExceptionTransformation.cs b/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/EntityNotFoundExceptionTransformation.cs index db60277..0b2a3ef 100644 --- a/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/EntityNotFoundExceptionTransformation.cs +++ b/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/EntityNotFoundExceptionTransformation.cs @@ -6,13 +6,17 @@ namespace GerstITS.Examples.Api.ExceptionHandling; public class EntityNotFoundExceptionTransformation : ExceptionTransformationBase { + #region Methods + protected override ExceptionTransformationInfo CreateExceptionTransformationInfo(EntityNotFoundException exception, string ticketId) { return new ExceptionTransformationInfo - { - StatusCode = HttpStatusCode.NotFound, - ReasonPhrase = "Enitity nicht gefunden", - Details = exception.Message - }; - } + { + StatusCode = HttpStatusCode.NotFound, + ReasonPhrase = "Enitity nicht gefunden", + Details = exception.Message + }; + } + + #endregion } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/ValidationExceptionTransformation.cs b/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/ValidationExceptionTransformation.cs index 36f3853..34bd83f 100644 --- a/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/ValidationExceptionTransformation.cs +++ b/GerstITS.Examples.Api/Common/ExceptionHandling/Transformations/ValidationExceptionTransformation.cs @@ -11,11 +11,11 @@ internal sealed class ValidationExceptionTransformation : ExceptionTransformatio protected override ExceptionTransformationInfo CreateExceptionTransformationInfo(ValidationException exception, string ticketId) { return new ExceptionTransformationInfo - { - StatusCode = HttpStatusCode.BadRequest, - ReasonPhrase = "Validierungsfehler", - Details = exception.Message - }; + { + StatusCode = HttpStatusCode.BadRequest, + ReasonPhrase = "Validierungsfehler", + Details = exception.Message + }; } #endregion diff --git a/GerstITS.Examples.Api/Common/StartupTasks/ExampleStartupTask.cs b/GerstITS.Examples.Api/Common/StartupTasks/ExampleStartupTask.cs index 7aef036..eb8de52 100644 --- a/GerstITS.Examples.Api/Common/StartupTasks/ExampleStartupTask.cs +++ b/GerstITS.Examples.Api/Common/StartupTasks/ExampleStartupTask.cs @@ -17,7 +17,7 @@ internal class ExampleStartupTask : IStartupTask #region Construtcors public ExampleStartupTask(IExampleProvider provider, - IJsonConvert jsonConvert) + IJsonConvert jsonConvert) { _jsonConvert = jsonConvert; _provider = provider; diff --git a/GerstITS.Examples.Api/Controllers/1.0/ExampleController.cs b/GerstITS.Examples.Api/Controllers/1.0/ExampleController.cs index 3678c84..48b87b3 100644 --- a/GerstITS.Examples.Api/Controllers/1.0/ExampleController.cs +++ b/GerstITS.Examples.Api/Controllers/1.0/ExampleController.cs @@ -24,7 +24,7 @@ public class ExampleController : FluentApiControllerBase #region Constructors public ExampleController(IExampleProvider provider, - IValidator validator) + IValidator validator) : base(validator) { _provider = provider; diff --git a/GerstITS.Examples.Api/Controllers/1.1/ExampleController.cs b/GerstITS.Examples.Api/Controllers/1.1/ExampleController.cs index 7e57907..9d75d89 100644 --- a/GerstITS.Examples.Api/Controllers/1.1/ExampleController.cs +++ b/GerstITS.Examples.Api/Controllers/1.1/ExampleController.cs @@ -24,7 +24,7 @@ public class ExampleController : FluentApiControllerBase #region Constructors public ExampleController(IExampleProvider provider, - IValidator validator) + IValidator validator) : base(validator) { _provider = provider; @@ -44,7 +44,7 @@ public class ExampleController : FluentApiControllerBase public IActionResult Get(int id) { return Api().Use(id) - .Get(_provider.GetById_v1_1); + .Get(_provider.GetById_v1_1); } #endregion diff --git a/GerstITS.Examples.Api/GerstITS.Examples.Api.csproj b/GerstITS.Examples.Api/GerstITS.Examples.Api.csproj index 12c1c26..78446e0 100644 --- a/GerstITS.Examples.Api/GerstITS.Examples.Api.csproj +++ b/GerstITS.Examples.Api/GerstITS.Examples.Api.csproj @@ -37,10 +37,10 @@ - + - + @@ -49,19 +49,20 @@ - + - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + @@ -74,4 +75,8 @@ + + + + diff --git a/GerstITS.Examples.Api/Module.Mvc.cs b/GerstITS.Examples.Api/Module.Mvc.cs deleted file mode 100644 index 3ae7880..0000000 --- a/GerstITS.Examples.Api/Module.Mvc.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; - -namespace GerstITS.Examples.Api; - -public sealed partial class Module -{ - #region Methods - - private static void RegisterMvc(IServiceCollection container) - { - //container.AddTransient, ApiMvcOptions>(); - //container.AddTransient, MvcJsonOptions>(); - - container.AddMvc() - .AddNewtonsoftJson(); - } - - #endregion -} \ No newline at end of file diff --git a/GerstITS.Examples.Api/Module.cs b/GerstITS.Examples.Api/Module.cs index 5c44be6..89610a9 100644 --- a/GerstITS.Examples.Api/Module.cs +++ b/GerstITS.Examples.Api/Module.cs @@ -11,7 +11,6 @@ public sealed partial class Module : IIoCModule { RegisterConfigurations(container); RegisterExceptionHandling(container); - RegisterMvc(container); RegisterStartupTasks(container); } diff --git a/GerstITS.Examples.Api/Program.cs b/GerstITS.Examples.Api/Program.cs index 87b0f28..58ce567 100644 --- a/GerstITS.Examples.Api/Program.cs +++ b/GerstITS.Examples.Api/Program.cs @@ -15,7 +15,7 @@ public class Program : ProgramBase protected override void ConfigureWebHost(IWebHostBuilder webHostBuilder) { webHostBuilder.UseLogging() - .UseStartup(); + .UseStartup(); } #endregion diff --git a/GerstITS.Examples.Api/Properties/launchSettings.json b/GerstITS.Examples.Api/Properties/launchSettings.json index b4123d5..1757c05 100644 --- a/GerstITS.Examples.Api/Properties/launchSettings.json +++ b/GerstITS.Examples.Api/Properties/launchSettings.json @@ -14,6 +14,14 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } + }, + "GerstITS.Examples.Api": { + "commandName": "Project", + "launchBrowser": false, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:5000" } } } \ No newline at end of file diff --git a/GerstITS.Examples.Api/Startup.cs b/GerstITS.Examples.Api/Startup.cs index 35fdf4a..cd6fff1 100644 --- a/GerstITS.Examples.Api/Startup.cs +++ b/GerstITS.Examples.Api/Startup.cs @@ -16,7 +16,7 @@ public class Startup : BootstrapperStartupBase applicationBuilder.UsePreconfiguredHsts(); else applicationBuilder.UseDeveloperExceptionPage() - .UseSwagger(); + .UseSwagger(); applicationBuilder.UsePreconfiguredCors() .UsePreconfiguredForwardedHeaders() diff --git a/GerstITS.Examples.Jobs.SayHelloWorld/GerstITS.Examples.Jobs.SayHelloWorld.csproj b/GerstITS.Examples.Jobs.SayHelloWorld/GerstITS.Examples.Jobs.SayHelloWorld.csproj index 955f7ba..03ae824 100644 --- a/GerstITS.Examples.Jobs.SayHelloWorld/GerstITS.Examples.Jobs.SayHelloWorld.csproj +++ b/GerstITS.Examples.Jobs.SayHelloWorld/GerstITS.Examples.Jobs.SayHelloWorld.csproj @@ -37,7 +37,7 @@ - + diff --git a/GerstITS.Examples.Jobs.SayHelloWorld/Jobs/SayHelloWorldJob.cs b/GerstITS.Examples.Jobs.SayHelloWorld/Jobs/SayHelloWorldJob.cs index 9ca3838..5071f65 100644 --- a/GerstITS.Examples.Jobs.SayHelloWorld/Jobs/SayHelloWorldJob.cs +++ b/GerstITS.Examples.Jobs.SayHelloWorld/Jobs/SayHelloWorldJob.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using System.Threading; -using GerstITS.Data; using GerstITS.Examples.Jobs.SayHelloWorld.Configurations; using GerstITS.Job; using GerstITS.System.Environment; diff --git a/GerstITS.Examples.Logic/GerstITS.Examples.Logic.csproj b/GerstITS.Examples.Logic/GerstITS.Examples.Logic.csproj index 899a713..62a0e6b 100644 --- a/GerstITS.Examples.Logic/GerstITS.Examples.Logic.csproj +++ b/GerstITS.Examples.Logic/GerstITS.Examples.Logic.csproj @@ -33,14 +33,14 @@ - + - - + +