Initial commit
This commit is contained in:
16
.gitignore
vendored
Normal file
16
.gitignore
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
################################################################################
|
||||
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
|
||||
################################################################################
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
[Ll]og/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
.vs/
|
||||
|
||||
*.user
|
||||
*.suo
|
||||
*.dll
|
||||
*.pdb
|
||||
*.xml
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Net;
|
||||
using GerstITS.Data;
|
||||
using GerstITS.Web.Api.ExceptionHandling;
|
||||
|
||||
namespace GerstITS.Examples.Api.ExceptionHandling
|
||||
{
|
||||
public class EntityNotFoundExceptionTransformation : ExceptionTransformationBase<EntityNotFoundException>
|
||||
{
|
||||
protected override ExceptionTransformationInfo CreateExceptionTransformationInfo(EntityNotFoundException exception, string ticketId)
|
||||
{
|
||||
return new ExceptionTransformationInfo
|
||||
{
|
||||
StatusCode = HttpStatusCode.NotFound,
|
||||
ReasonPhrase = "Enitity nicht gefunden",
|
||||
Details = exception.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Net;
|
||||
using GerstITS.Web.Api.ExceptionHandling;
|
||||
|
||||
namespace GerstITS.Examples.Api.ExceptionHandling
|
||||
{
|
||||
internal sealed class ValidationExceptionTransformation : ExceptionTransformationBase<ValidationException>
|
||||
{
|
||||
#region Methods
|
||||
|
||||
protected override ExceptionTransformationInfo CreateExceptionTransformationInfo(ValidationException exception, string ticketId)
|
||||
{
|
||||
return new ExceptionTransformationInfo
|
||||
{
|
||||
StatusCode = HttpStatusCode.BadRequest,
|
||||
ReasonPhrase = "Validierungsfehler",
|
||||
Details = exception.Message
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Diagnostics;
|
||||
using GerstITS.Examples.Logic.Example;
|
||||
using GerstITS.IoC;
|
||||
using GerstITS.System.Json;
|
||||
|
||||
namespace GerstITS.Examples.Api.StartupTasks
|
||||
{
|
||||
internal class ExampleStartupTask : IStartupTask
|
||||
{
|
||||
#region Fields#
|
||||
|
||||
private readonly IExampleProvider _provider;
|
||||
private readonly IJsonConvert _jsonConvert;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Construtcors
|
||||
|
||||
public ExampleStartupTask(IExampleProvider provider,
|
||||
IJsonConvert jsonConvert)
|
||||
{
|
||||
_jsonConvert = jsonConvert;
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStartupTask
|
||||
|
||||
public StartupPriorities Priority => StartupPriorities.Normal;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
Debug.WriteLine($"---> {nameof(ExampleStartupTask)}: {_jsonConvert.Serialize(_provider.GetById(123))}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using GerstITS.Web.Api.Swagger;
|
||||
|
||||
namespace GerstITS.Examples.Api.Swagger
|
||||
{
|
||||
internal class LicenseConfiguration : ILicense
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public string Name { get; set; }
|
||||
public Uri Url { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using GerstITS.Web.Api.Swagger;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
namespace GerstITS.Examples.Api.Swagger
|
||||
{
|
||||
internal sealed class SwaggerSecurityConfiguration : IOpenApiSecuritySchemeConfiguration
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public bool AllowAnonymous { get; set; }
|
||||
public string HttpHeaderKey { get; set; }
|
||||
public string Scheme { get; set; }
|
||||
public SecuritySchemeType SchemeType { get; set; }
|
||||
public ParameterLocation ParameterLocation { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using GerstITS.System.Configurations;
|
||||
using GerstITS.Web.Api.Swagger;
|
||||
|
||||
namespace GerstITS.Examples.Api.Swagger
|
||||
{
|
||||
internal class WebApiConfiguration : ISwaggerConfiguration, IConfiguration
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public WebApiConfiguration()
|
||||
{
|
||||
var currentAssembly = typeof(WebApiConfiguration).Assembly;
|
||||
var fileVersionInfo = FileVersionInfo.GetVersionInfo(currentAssembly.Location);
|
||||
|
||||
Company = fileVersionInfo.CompanyName;
|
||||
Name = fileVersionInfo.ProductName;
|
||||
Release = currentAssembly.GetName().Version;
|
||||
|
||||
TermsOfService = new Uri("https://en.wikipedia.org/wiki/Terms_of_service");
|
||||
License = new LicenseConfiguration
|
||||
{
|
||||
Name = "MIT",
|
||||
Url = new Uri("https://opensource.org/licenses/MIT")
|
||||
};
|
||||
SupportEMail = "info@examples.net";
|
||||
|
||||
Security = new SwaggerSecurityConfiguration
|
||||
{
|
||||
AllowAnonymous = true
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISwaggerConfiguration
|
||||
|
||||
public string Name { get; }
|
||||
public string Company { get; }
|
||||
public string SupportEMail { get; }
|
||||
public Uri TermsOfService { get; }
|
||||
public ILicense License { get; }
|
||||
public Version Release { get; }
|
||||
public IOpenApiSecuritySchemeConfiguration Security { get; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
12
GerstITS.Examples.Api/Common/Versioning/Versions.cs
Normal file
12
GerstITS.Examples.Api/Common/Versioning/Versions.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace GerstITS.Examples.Api.Versioning
|
||||
{
|
||||
public static class Versions
|
||||
{
|
||||
#region Versions
|
||||
|
||||
public const string _1_0 = "1.0";
|
||||
public const string _1_1 = "1.1";
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
52
GerstITS.Examples.Api/Controllers/1.0/ExampleController.cs
Normal file
52
GerstITS.Examples.Api/Controllers/1.0/ExampleController.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using GerstITS.Examples.Api.Versioning;
|
||||
using GerstITS.Examples.Logic.Example;
|
||||
using GerstITS.Validation;
|
||||
using GerstITS.Web.Api;
|
||||
using GerstITS.Web.Api.FluentApi;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace GerstITS.Examples.Api.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Controller is deprecated use newer version.
|
||||
/// </summary>
|
||||
[ApiController,
|
||||
ApiVersion(Versions._1_0, Deprecated = true),
|
||||
Route(ApplicationEnvironment.WebApi.ControllerRouteTemplate)]
|
||||
public class ExampleController : FluentApiControllerBase
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private readonly IExampleProvider _provider;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ExampleController(IExampleProvider provider,
|
||||
IValidator validator)
|
||||
: base(validator)
|
||||
{
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the example data by id.
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>Returns Example data.</returns>
|
||||
[HttpGet,
|
||||
Route("{id}")]
|
||||
public IActionResult Get(int id)
|
||||
{
|
||||
return Api().Use(id)
|
||||
.Get(_provider.GetById);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
52
GerstITS.Examples.Api/Controllers/1.1/ExampleController.cs
Normal file
52
GerstITS.Examples.Api/Controllers/1.1/ExampleController.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using GerstITS.Examples.Api.Versioning;
|
||||
using GerstITS.Examples.Logic.Example;
|
||||
using GerstITS.Validation;
|
||||
using GerstITS.Web.Api;
|
||||
using GerstITS.Web.Api.FluentApi;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace GerstITS.Examples.Api.Controllers._1._1
|
||||
{
|
||||
/// <summary>
|
||||
/// Is responsible to get employee organization assignment examples.
|
||||
/// </summary>
|
||||
[ApiController,
|
||||
ApiVersion(Versions._1_1),
|
||||
Route(ApplicationEnvironment.WebApi.ControllerRouteTemplate)]
|
||||
public class ExampleController : FluentApiControllerBase
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private readonly IExampleProvider _provider;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ExampleController(IExampleProvider provider,
|
||||
IValidator validator)
|
||||
: base(validator)
|
||||
{
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets a employee organization assignment by specified id.
|
||||
/// </summary>
|
||||
/// <param name="id">Id of the employee organization assignment.</param>
|
||||
/// <returns>Returns an employee organization assignment</returns>
|
||||
[HttpGet,
|
||||
Route("{id}")]
|
||||
public IActionResult Get(int id)
|
||||
{
|
||||
return Api().Use(id)
|
||||
.Get(_provider.GetById_v1_1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<Company>ITSCare GbR</Company>
|
||||
<Authors>ITSCare GbR</Authors>
|
||||
<Copyright>Copyright © ITSCare GbR 2021</Copyright>
|
||||
<Product>ITSCare Example WebApi</Product>
|
||||
<Version>0.0.0.0</Version>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<AssemblyInformationalVersion>0.0.0.0</AssemblyInformationalVersion>
|
||||
<FileVersion>0.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>bin\Debug\net5.0\ITSCare.Example.Api.xml</DocumentationFile>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>bin\Release\net5.0\ITSCare.Example.Api.xml</DocumentationFile>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ITSCare.Common\ITSCare.Common.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Data.EntityFramework\ITSCare.Data.EntityFramework.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Data\ITSCare.Data.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.IoC.DotNetCore\ITSCare.IoC.DotNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.IoC\ITSCare.IoC.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Job.Scheduling\ITSCare.Job.Scheduling.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Job\ITSCare.Job.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.Authentication.SkyNet\ITSCare.Web.Api.Authentication.SkyNet.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.Cors.DotNetCore\ITSCare.Web.Api.Cors.DotNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.DotNetCore\ITSCare.Web.Api.DotNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.Swagger\ITSCare.Web.Api.Swagger.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api\ITSCare.Web.Api.csproj" />
|
||||
<ProjectReference Include="..\ITSCare.Example.Jobs.SayHelloWorld\ITSCare.Example.Jobs.SayHelloWorld.csproj" />
|
||||
<ProjectReference Include="..\ITSCare.Example.Logic\ITSCare.Example.Logic.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,63 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<Company>ITSCare GbR</Company>
|
||||
<Authors>ITSCare GbR</Authors>
|
||||
<Copyright>Copyright © ITSCare GbR 2021</Copyright>
|
||||
<Product>ITSCare Example WebApi</Product>
|
||||
<Version>0.0.0.0</Version>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<AssemblyInformationalVersion>0.0.0.0</AssemblyInformationalVersion>
|
||||
<FileVersion>0.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>bin\Debug\net5.0\ITSCare.Example.Api.xml</DocumentationFile>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>bin\Release\net5.0\ITSCare.Example.Api.xml</DocumentationFile>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ITSCare.Common\ITSCare.Common.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Data.EntityFramework\ITSCare.Data.EntityFramework.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Data\ITSCare.Data.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.IoC.DotNetCore\ITSCare.IoC.DotNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.IoC\ITSCare.IoC.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Job.Scheduling\ITSCare.Job.Scheduling.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Job\ITSCare.Job.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.Cors.DotNetCore\ITSCare.Web.Api.Cors.DotNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.DotNetCore\ITSCare.Web.Api.DotNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.Swagger\ITSCare.Web.Api.Swagger.csproj" />
|
||||
<ProjectReference Include="..\ITSCare.Example.Jobs.SayHelloWorld\ITSCare.Example.Jobs.SayHelloWorld.csproj" />
|
||||
<ProjectReference Include="..\ITSCare.Example.Logic\ITSCare.Example.Logic.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,59 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<Company>ITSCare GbR</Company>
|
||||
<Authors>ITSCare GbR</Authors>
|
||||
<Copyright>Copyright © ITSCare GbR 2021</Copyright>
|
||||
<Product>ITSCare Example WebApi</Product>
|
||||
<Version>0.0.0.0</Version>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<AssemblyInformationalVersion>0.0.0.0</AssemblyInformationalVersion>
|
||||
<FileVersion>0.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>bin\Debug\net5.0\ITSCare.Example.Api.xml</DocumentationFile>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>bin\Release\net5.0\ITSCare.Example.Api.xml</DocumentationFile>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ITSCare.Common\ITSCare.Common.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Data.EntityFramework\ITSCare.Data.EntityFramework.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Data\ITSCare.Data.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.IoC.DotNetCore\ITSCare.IoC.DotNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.IoC\ITSCare.IoC.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Job\ITSCare.Job.csproj" />
|
||||
<ProjectReference Include="..\ITSCare.Example.Jobs.SayHelloWorld\ITSCare.Example.Jobs.SayHelloWorld.csproj" />
|
||||
<ProjectReference Include="..\ITSCare.Example.Logic\ITSCare.Example.Logic.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
68
GerstITS.Examples.Api/GerstITS - Backup.Examples.Api.csproj
Normal file
68
GerstITS.Examples.Api/GerstITS - Backup.Examples.Api.csproj
Normal file
@@ -0,0 +1,68 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<Company>ITSCare GbR</Company>
|
||||
<Authors>ITSCare GbR</Authors>
|
||||
<Copyright>Copyright © ITSCare GbR 2021</Copyright>
|
||||
<Product>ITSCare Example WebApi</Product>
|
||||
<Version>0.0.0.0</Version>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<AssemblyInformationalVersion>0.0.0.0</AssemblyInformationalVersion>
|
||||
<FileVersion>0.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>bin\Debug\net5.0\ITSCare.Example.Api.xml</DocumentationFile>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>bin\Release\net5.0\ITSCare.Example.Api.xml</DocumentationFile>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ITSCare.Common\ITSCare.Common.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Data.EntityFramework\ITSCare.Data.EntityFramework.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Data\ITSCare.Data.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.IoC.DotNetCore\ITSCare.IoC.DotNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.IoC\ITSCare.IoC.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Job.Scheduling\ITSCare.Job.Scheduling.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Job\ITSCare.Job.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.System\ITSCare.System.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Validation\ITSCare.Validation.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.Authentication.SkyNet\ITSCare.Web.Api.Authentication.SkyNet.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.Cors.DotNetCore\ITSCare.Web.Api.Cors.DotNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.DotNetCore\ITSCare.Web.Api.DotNetCore.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api.Swagger\ITSCare.Web.Api.Swagger.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web.Api\ITSCare.Web.Api.csproj" />
|
||||
<ProjectReference Include="..\..\ITSCare.Web\ITSCare.Web.csproj" />
|
||||
<ProjectReference Include="..\ITSCare.Example.Jobs.SayHelloWorld\ITSCare.Example.Jobs.SayHelloWorld.csproj" />
|
||||
<ProjectReference Include="..\ITSCare.Example.Logic\ITSCare.Example.Logic.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
67
GerstITS.Examples.Api/GerstITS.Examples.Api.csproj
Normal file
67
GerstITS.Examples.Api/GerstITS.Examples.Api.csproj
Normal file
@@ -0,0 +1,67 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<Company>ITSCare GbR</Company>
|
||||
<Authors>ITSCare GbR</Authors>
|
||||
<Copyright>Copyright © ITSCare GbR 2021</Copyright>
|
||||
<Product>ITSCare Example WebApi</Product>
|
||||
<Version>0.0.0.0</Version>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<AssemblyInformationalVersion>0.0.0.0</AssemblyInformationalVersion>
|
||||
<FileVersion>0.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>bin\Debug\net5.0\ITSCare.Example.Api.xml</DocumentationFile>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>1591</NoWarn>
|
||||
<DocumentationFile>bin\Release\net5.0\ITSCare.Example.Api.xml</DocumentationFile>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GerstITS.AutoMapper" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Common" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Data" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.IoC" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.IoC.DotNetCore" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Job" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Job.Scheduling" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Search" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.System" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Validation" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Web" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Web.Api" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Web.Api.Swagger" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Web.Rest" Version="2021.6.17" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.7" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.7">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GerstITS.Examples.Jobs.SayHelloWorld\GerstITS.Examples.Jobs.SayHelloWorld.csproj" />
|
||||
<ProjectReference Include="..\GerstITS.Examples.Logic\GerstITS.Examples.Logic.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,7 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=common/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=common_005Cexceptionhandling_005Ctransformations/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=common_005Cswagger_005Cconfiguration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=common_005Cversioning/@EntryIndexedValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=controllers_005C1_002E0/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=controllers_005Callversion/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
18
GerstITS.Examples.Api/Module.ExceptionHandling.cs
Normal file
18
GerstITS.Examples.Api/Module.ExceptionHandling.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using GerstITS.Examples.Api.ExceptionHandling;
|
||||
using GerstITS.Web.Api.ExceptionHandling.Extensions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.Api
|
||||
{
|
||||
public sealed partial class Module
|
||||
{
|
||||
#region Methods
|
||||
|
||||
private static void RegisterExceptionHandling(IServiceCollection container)
|
||||
{
|
||||
container.RegisterExceptionTransformationsOf<ValidationExceptionTransformation>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
22
GerstITS.Examples.Api/Module.Mvc.cs
Normal file
22
GerstITS.Examples.Api/Module.Mvc.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
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<IConfigureOptions<MvcOptions>, ApiMvcOptions>();
|
||||
//container.AddTransient<IConfigureOptions<MvcNewtonsoftJsonOptions>, MvcJsonOptions>();
|
||||
|
||||
container.AddMvc()
|
||||
.AddNewtonsoftJson()
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Latest);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
18
GerstITS.Examples.Api/Module.StartupTasks.cs
Normal file
18
GerstITS.Examples.Api/Module.StartupTasks.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using GerstITS.Examples.Api.StartupTasks;
|
||||
using GerstITS.IoC.DotNetCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.Api
|
||||
{
|
||||
public sealed partial class Module
|
||||
{
|
||||
#region Methods
|
||||
|
||||
private static void RegisterStartupTasks(IServiceCollection container)
|
||||
{
|
||||
container.RegisterStartupTasksOf<ExampleStartupTask>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
18
GerstITS.Examples.Api/Module.Swagger.cs
Normal file
18
GerstITS.Examples.Api/Module.Swagger.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using GerstITS.Examples.Api.Swagger;
|
||||
using GerstITS.Web.Api.Swagger;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.Api
|
||||
{
|
||||
public sealed partial class Module
|
||||
{
|
||||
#region Methods
|
||||
|
||||
private static void RegisterSwagger(IServiceCollection container)
|
||||
{
|
||||
container.AddSingleton<ISwaggerConfiguration, WebApiConfiguration>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
20
GerstITS.Examples.Api/Module.cs
Normal file
20
GerstITS.Examples.Api/Module.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using GerstITS.IoC;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.Api
|
||||
{
|
||||
public sealed partial class Module : IIoCModule<IServiceCollection>
|
||||
{
|
||||
#region IIoCModule
|
||||
|
||||
public void RegisterComponents(IServiceCollection container)
|
||||
{
|
||||
RegisterExceptionHandling(container);
|
||||
RegisterMvc(container);
|
||||
RegisterStartupTasks(container);
|
||||
RegisterSwagger(container);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
21
GerstITS.Examples.Api/Program.cs
Normal file
21
GerstITS.Examples.Api/Program.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using GerstITS.Web.Api.Hosting;
|
||||
|
||||
namespace GerstITS.Examples.Api
|
||||
{
|
||||
public class Program : ProgramBase<Program>
|
||||
{
|
||||
#region Methods
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Run(args);
|
||||
}
|
||||
|
||||
protected override void ConfigureWebHost(IWebHostBuilder webHostBuilder)
|
||||
{
|
||||
webHostBuilder.UseStartup<Startup>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
27
GerstITS.Examples.Api/Properties/launchSettings.json
Normal file
27
GerstITS.Examples.Api/Properties/launchSettings.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:61531/",
|
||||
"sslPort": 44353
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"ITSCare.Example.Api": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
||||
32
GerstITS.Examples.Api/Startup.cs
Normal file
32
GerstITS.Examples.Api/Startup.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using GerstITS.Web.Api;
|
||||
using GerstITS.Web.Api.Builder;
|
||||
using GerstITS.Web.Api.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace GerstITS.Examples.Api
|
||||
{
|
||||
public class Startup : BootstrapperStartupBase
|
||||
{
|
||||
#region Methods
|
||||
|
||||
protected override void ConfigureApplication(IApplicationBuilder applicationBuilder, IWebHostEnvironment webHostEnvironment)
|
||||
{
|
||||
if (webHostEnvironment.IsDevelopment())
|
||||
applicationBuilder.UseDeveloperExceptionPage()
|
||||
.UseSwagger();
|
||||
else
|
||||
applicationBuilder.UseHsts();
|
||||
|
||||
applicationBuilder.UseHttpsRedirection()
|
||||
.UseAuthentication()
|
||||
.UseAuthorization()
|
||||
.UseRouting()
|
||||
.UseEndpoints(endpoints => endpoints.MapControllers())
|
||||
.UseRewriteUnknownPathsToIndexSite(ApplicationEnvironment.WebApi.BaseUrl)
|
||||
.UseStaticFiles();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
22
GerstITS.Examples.Api/appsettings.json
Normal file
22
GerstITS.Examples.Api/appsettings.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"WebApi": {
|
||||
"SupportEMail": "support@itscare.de"
|
||||
},
|
||||
"SkyNet": {
|
||||
"AppId": 86,
|
||||
"Audience": "39CE2111-475C-42FE-88F7-9B7A29D0262C"
|
||||
},
|
||||
"LogPath": "log/{Date}.log",
|
||||
"SayHelloWorldJob": {
|
||||
"CronExpression": "*/30 * * * * ? *",
|
||||
"Name": "Example Job"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using GerstITS.Job.Scheduling;
|
||||
using GerstITS.System.Configurations;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace GerstITS.Examples.Jobs.SayHelloWorld.Configurations
|
||||
{
|
||||
public class SayHelloWorldJobConfiguration : JobSchedulingConfigurationBase
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public SayHelloWorldJobConfiguration(Microsoft.Extensions.Configuration.IConfiguration configuration)
|
||||
: base(configuration)
|
||||
{
|
||||
var prefix = this.ToConfigurationPrefix();
|
||||
|
||||
Name = configuration.GetValue<string>($"{prefix}:{nameof(Name)}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Company>ITSCare GbR</Company>
|
||||
<Authors>ITSCare GbR</Authors>
|
||||
<Copyright>Copyright © ITSCare GbR 2021</Copyright>
|
||||
<Product>ITSCare GbR Example Job</Product>
|
||||
<Version>0.0.0.0</Version>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<AssemblyInformationalVersion>0.0.0.0</AssemblyInformationalVersion>
|
||||
<FileVersion>0.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GerstITS.Data" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.IoC" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.IoC.DotNetCore" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Job" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Job.Scheduling" Version="2021.6.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Module.Jobs.cs">
|
||||
<DependentUpon>Module.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=configurations/@EntryIndexedValue">False</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using GerstITS.Data;
|
||||
using GerstITS.Examples.Jobs.SayHelloWorld.Configurations;
|
||||
using GerstITS.Job;
|
||||
using GerstITS.System.Environment;
|
||||
using Quartz;
|
||||
|
||||
namespace GerstITS.Examples.Jobs.SayHelloWorld.Jobs
|
||||
{
|
||||
[DisallowConcurrentExecution]
|
||||
public class SayHelloWorldJob : JobBase
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private readonly SayHelloWorldJobConfiguration _configuration;
|
||||
private readonly Stopwatch _stopWatch;
|
||||
private readonly IRepository _repository;
|
||||
private readonly ISystemClock _systemClock;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cosntructors
|
||||
|
||||
public SayHelloWorldJob(SayHelloWorldJobConfiguration configuration,
|
||||
IRepository repository,
|
||||
ISystemClock systemClock)
|
||||
{
|
||||
_systemClock = systemClock;
|
||||
_repository = repository;
|
||||
_configuration = configuration;
|
||||
_stopWatch = new Stopwatch();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override void Execute()
|
||||
{
|
||||
_stopWatch.Restart();
|
||||
Thread.Sleep(4000);
|
||||
var now = _systemClock.UtcNow;
|
||||
|
||||
_stopWatch.Stop();
|
||||
Debug.WriteLine($"---> Say hello to world from {_configuration.Name}, Duration: {_stopWatch.ElapsedMilliseconds / 1000}s");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
20
GerstITS.Examples.Jobs.SayHelloWorld/Module.cs
Normal file
20
GerstITS.Examples.Jobs.SayHelloWorld/Module.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using GerstITS.Examples.Jobs.SayHelloWorld.Configurations;
|
||||
using GerstITS.Examples.Jobs.SayHelloWorld.Jobs;
|
||||
using GerstITS.IoC;
|
||||
using GerstITS.Job.Scheduling;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.Jobs.SayHelloWorld
|
||||
{
|
||||
public sealed class Module : IIoCModule<IServiceCollection>
|
||||
{
|
||||
#region IIoCModule
|
||||
|
||||
public void RegisterComponents(IServiceCollection container)
|
||||
{
|
||||
container.RegisterJob<SayHelloWorldJob, SayHelloWorldJobConfiguration>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
13
GerstITS.Examples.Logic/Example/Contracts/Example.cs
Normal file
13
GerstITS.Examples.Logic/Example/Contracts/Example.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace GerstITS.Examples.Logic.Example
|
||||
{
|
||||
public class Example
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace GerstITS.Examples.Logic.Example
|
||||
{
|
||||
public interface IExampleProvider
|
||||
{
|
||||
Example GetById(int id);
|
||||
Example GetById_v1_1(int id);
|
||||
}
|
||||
}
|
||||
51
GerstITS.Examples.Logic/Example/ExampleProvider.cs
Normal file
51
GerstITS.Examples.Logic/Example/ExampleProvider.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using AutoMapper;
|
||||
using GerstITS.Data;
|
||||
|
||||
namespace GerstITS.Examples.Logic.Example
|
||||
{
|
||||
internal sealed class ExampleProvider : IExampleProvider
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ExampleProvider(IMapper mapper)
|
||||
{
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IExampleProvider
|
||||
|
||||
public Example GetById(int id)
|
||||
{
|
||||
ThrowsAnExceptionIfEntityIsNotFound(id);
|
||||
|
||||
return _mapper.Map<Example>(id);
|
||||
}
|
||||
|
||||
public Example GetById_v1_1(int id)
|
||||
{
|
||||
ThrowsAnExceptionIfEntityIsNotFound(id);
|
||||
|
||||
return _mapper.Map<Example>(id);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private static void ThrowsAnExceptionIfEntityIsNotFound(int id)
|
||||
{
|
||||
if (id % 2 == 0)
|
||||
throw new EntityNotFoundException($"Example mit der Id '{id}' nicht gefunden.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
19
GerstITS.Examples.Logic/Example/Mappings/IntegerMapping.cs
Normal file
19
GerstITS.Examples.Logic/Example/Mappings/IntegerMapping.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using AutoMapper;
|
||||
|
||||
namespace GerstITS.Examples.Logic.Example
|
||||
{
|
||||
internal sealed class IntegerMapping : Profile
|
||||
{
|
||||
#region Construtcors
|
||||
|
||||
public IntegerMapping()
|
||||
{
|
||||
CreateMap<int, Example>()
|
||||
.ForMember(x => x.FirstName, m => m.MapFrom((s,t) => $"First Name {s}"))
|
||||
.ForMember(x => x.LastName, m => m.MapFrom((s,t) => $"Last Name {s}"))
|
||||
.ForMember(x => x.Description, m => m.MapFrom((s,t) => $"Useful description for id '{s}'"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
54
GerstITS.Examples.Logic/GerstITS.Examples.Logic.csproj
Normal file
54
GerstITS.Examples.Logic/GerstITS.Examples.Logic.csproj
Normal file
@@ -0,0 +1,54 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Company>ITSCare GbR</Company>
|
||||
<Authors>ITSCare GbR</Authors>
|
||||
<Copyright>Copyright © ITSCare GbR 2021</Copyright>
|
||||
<Product>ITSCare GbR Example Logic</Product>
|
||||
<Version>0.0.0.0</Version>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<AssemblyInformationalVersion>0.0.0.0</AssemblyInformationalVersion>
|
||||
<FileVersion>0.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="10.1.1" />
|
||||
<PackageReference Include="FluentValidation" Version="10.2.3" />
|
||||
<PackageReference Include="GerstITS.AutoMapper" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Data" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.IoC" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.IoC.DotNetCore" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Search" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Validation" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Web.Api" Version="2021.6.17" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Module.Example.cs">
|
||||
<DependentUpon>Module.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Module.Shared.cs">
|
||||
<DependentUpon>Module.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,13 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=country_005Ccontracts/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=country_005Cmapping/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=country_005Csearch/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=country_005Csearch_005Cextensions/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=country_005Csearch_005Crules/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=country_005Cvalidations/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=example_005Ccontracts/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=example_005Cextensions/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=example_005Cmappings/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=example_005Cvalidations/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=shared_005Cbases/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=shared_005Cextensions/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
20
GerstITS.Examples.Logic/Module.Example.cs
Normal file
20
GerstITS.Examples.Logic/Module.Example.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using GerstITS.AutoMapper;
|
||||
using GerstITS.Examples.Logic.Example;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.Logic
|
||||
{
|
||||
public sealed partial class Module
|
||||
{
|
||||
#region Methods
|
||||
|
||||
private static void RegisterExample(IServiceCollection container)
|
||||
{
|
||||
container.RegisterMappingsOf<IExampleProvider>();
|
||||
|
||||
container.AddScoped<IExampleProvider, ExampleProvider>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
22
GerstITS.Examples.Logic/Module.Shared.cs
Normal file
22
GerstITS.Examples.Logic/Module.Shared.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using GerstITS.Examples.Logic.Shared.Search.Sorting;
|
||||
using GerstITS.Examples.Logic.Shared.Validation;
|
||||
using GerstITS.Search;
|
||||
using GerstITS.Validation;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.Logic
|
||||
{
|
||||
public sealed partial class Module
|
||||
{
|
||||
#region Methods
|
||||
|
||||
private static void RegisterShared(IServiceCollection container)
|
||||
{
|
||||
container.RegisterValidationRulesOf<IdValidationRule>();
|
||||
|
||||
container.AddScoped<ISortingProvider, SortingProvider>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
18
GerstITS.Examples.Logic/Module.cs
Normal file
18
GerstITS.Examples.Logic/Module.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using GerstITS.IoC;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.Logic
|
||||
{
|
||||
public sealed partial class Module : IIoCModule<IServiceCollection>
|
||||
{
|
||||
#region IIoCModule
|
||||
|
||||
public void RegisterComponents(IServiceCollection container)
|
||||
{
|
||||
RegisterExample(container);
|
||||
RegisterShared(container);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using GerstITS.Common;
|
||||
using GerstITS.Data;
|
||||
|
||||
namespace GerstITS.Examples.Logic.Shared
|
||||
{
|
||||
internal static class ISearchEngineExtensions
|
||||
{
|
||||
#region Methods
|
||||
|
||||
public static TEntity QueryBy<TEntity>(this IReadOnlyRepository repository, Expression<Func<TEntity, bool>> condition)
|
||||
where TEntity : IEntity
|
||||
{
|
||||
return repository.Query<TEntity>()
|
||||
.Where(condition)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public static TModel ThrowsAnExceptionIfNotFound<TModel, TKey>(this TModel model, TKey id)
|
||||
{
|
||||
if (model.IsNull())
|
||||
throw new EntityNotFoundException($"{typeof(TModel).Name} with id '{id}' not found.");
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace GerstITS.Examples.Logic.Shared.Search.Sorting
|
||||
{
|
||||
internal interface ISortable
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using GerstITS.Common;
|
||||
using GerstITS.Search;
|
||||
|
||||
namespace GerstITS.Examples.Logic.Shared.Search.Sorting
|
||||
{
|
||||
internal class SortingProvider : ISortingProvider
|
||||
{
|
||||
#region ISortingProvider
|
||||
|
||||
public bool CanSort<TItem>(IQueryable<TItem> query)
|
||||
{
|
||||
return typeof(TItem).IsAssignableTo(typeof(ISortable));
|
||||
}
|
||||
|
||||
public IQueryable<TItem> Sort<TItem>(IQueryable<TItem> query, ISorting sorting)
|
||||
{
|
||||
var propertyInfo = typeof(TItem).GetProperties()
|
||||
.SingleOrDefault(i => string.Equals(i.Name, sorting.SortBy, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
if (!CanSort(query) || propertyInfo.IsNull())
|
||||
return query;
|
||||
|
||||
var sortExpression = CreateSortExpression<TItem>(propertyInfo);
|
||||
|
||||
return (sorting.SortDirection == SortingDirections.Ascending
|
||||
? query.OrderBy(sortExpression)
|
||||
: query.OrderByDescending(sortExpression))
|
||||
.AsQueryable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private static Expression<Func<TItem, object>> CreateSortExpression<TItem>(MemberInfo propertyInfo)
|
||||
{
|
||||
var parameterExpression = Expression.Parameter(typeof(TItem), "x");
|
||||
var propertyExpression = Expression.Property(parameterExpression, propertyInfo.Name);
|
||||
var convertExpression = Expression.Convert(propertyExpression, typeof(object));
|
||||
|
||||
return Expression.Lambda<Func<TItem, object>>(convertExpression, parameterExpression);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FluentValidation;
|
||||
using GerstITS.Validation;
|
||||
|
||||
namespace GerstITS.Examples.Logic.Shared.Validation
|
||||
{
|
||||
internal sealed class IdValidationRule : ValidationRuleBase<int>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public IdValidationRule()
|
||||
{
|
||||
RuleFor(x => x)
|
||||
.GreaterThan(0)
|
||||
.OverridePropertyName("id");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Company>ITSCare GbR</Company>
|
||||
<Authors>ITSCare GbR</Authors>
|
||||
<Copyright>Copyright © ITSCare GbR 2021</Copyright>
|
||||
<Product>ITSCare GbR Example WebApi Client</Product>
|
||||
<Version>0.0.0.0</Version>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<AssemblyInformationalVersion>0.0.0.0</AssemblyInformationalVersion>
|
||||
<FileVersion>0.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<OutputType>Exe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GerstITS.Common" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.IoC" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.IoC.DotNetCore" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.System" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Web" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Web.Rest" Version="2021.6.17" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GerstITS.WebClients.Example.Api\GerstITS.Examples.WebClients.Examples.Api.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=tests_005Ccontracts/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
25
GerstITS.Examples.WebClient.Console/Module.cs
Normal file
25
GerstITS.Examples.WebClient.Console/Module.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using GerstITS.Examples.WebClient.Console.Tests;
|
||||
using GerstITS.IoC;
|
||||
using GerstITS.IoC.DotNetCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.WebClient.Console
|
||||
{
|
||||
public class Module : IIoCModule<IServiceCollection>
|
||||
{
|
||||
#region IIoCModule
|
||||
|
||||
public void RegisterComponents(IServiceCollection container)
|
||||
{
|
||||
container.AddTransient<IApplicationStart, TestRunner>();
|
||||
|
||||
container.AddTransient<IConfiguration>(c => new ConfigurationBuilder().SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
|
||||
.AddJsonFile("appsettings.json", false, true)
|
||||
.Build());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
31
GerstITS.Examples.WebClient.Console/Program.cs
Normal file
31
GerstITS.Examples.WebClient.Console/Program.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using GerstITS.IoC.DotNetCore;
|
||||
|
||||
namespace GerstITS.Examples.WebClient.Console
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private static readonly DotNetCoreApplicationBootstrapper _bootstrapper;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
static Program()
|
||||
{
|
||||
_bootstrapper = new DotNetCoreApplicationBootstrapper();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
_bootstrapper.Run();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
51
GerstITS.Examples.WebClient.Console/Tests/TestRunner.cs
Normal file
51
GerstITS.Examples.WebClient.Console/Tests/TestRunner.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using GerstITS.Examples.WebClients.Examples.Api;
|
||||
using GerstITS.IoC.DotNetCore;
|
||||
using GerstITS.Web.WebClients;
|
||||
|
||||
namespace GerstITS.Examples.WebClient.Console.Tests
|
||||
{
|
||||
internal sealed class TestRunner : IApplicationStart
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private readonly IWebClient _webClient;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Construtors
|
||||
|
||||
public TestRunner(IWebClient webClient)
|
||||
{
|
||||
_webClient = webClient;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITestRunner
|
||||
|
||||
public void Run()
|
||||
{
|
||||
var result1 = _webClient.Request<ICountry>()
|
||||
.Execute(c => c.Search(new SearchCriteria
|
||||
{ SortBy = nameof(Country.Name), SortDirection = SortingDirections.Descending, Skip = 5, Take = 5}));
|
||||
|
||||
var result2 = _webClient.Request<ICountry>()
|
||||
.Execute(c => c.Get(result1.Value.Result.First().Id));
|
||||
|
||||
var test3 = _webClient.Request<ICountry>()
|
||||
.Execute(c => c.Create(new Country {Name = $"Country-{Guid.NewGuid()}"}));
|
||||
|
||||
test3.Value.Name += "_Renamed";
|
||||
|
||||
var test4 = _webClient.Request<ICountry>()
|
||||
.Execute(c => c.Update(test3.Value));
|
||||
|
||||
var test5 = _webClient.Request<ICountry>()
|
||||
.Execute(c => c.Delete(test3.Value.Id));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
13
GerstITS.Examples.WebClient.Console/appsettings.json
Normal file
13
GerstITS.Examples.WebClient.Console/appsettings.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ExampleApiClient": {
|
||||
"BaseUrl": "https://localhost:44350/api/v1.1/"
|
||||
}
|
||||
}
|
||||
49
GerstITS.Examples.sln
Normal file
49
GerstITS.Examples.sln
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31321.278
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GerstITS.Examples.Api", "GerstITS.Examples.Api\GerstITS.Examples.Api.csproj", "{417B5C77-05BF-4562-9A1A-AEE0531B59C1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GerstITS.Examples.Jobs.SayHelloWorld", "GerstITS.Examples.Jobs.SayHelloWorld\GerstITS.Examples.Jobs.SayHelloWorld.csproj", "{A2E37A84-9331-48C7-8CCA-991528063087}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GerstITS.Examples.Logic", "GerstITS.Examples.Logic\GerstITS.Examples.Logic.csproj", "{4A83DB6A-01BB-4B56-B38B-268444F22B1E}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GerstITS.Examples.WebClient.Console", "GerstITS.Examples.WebClient.Console\GerstITS.Examples.WebClient.Console.csproj", "{A7AD8A07-C9C0-480B-A96B-2D03ACD57060}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GerstITS.Examples.WebClients.Examples.Api", "GerstITS.WebClients.Example.Api\GerstITS.Examples.WebClients.Examples.Api.csproj", "{34720C2D-09AD-41F4-B7CC-D703D9F24EDD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{417B5C77-05BF-4562-9A1A-AEE0531B59C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{417B5C77-05BF-4562-9A1A-AEE0531B59C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{417B5C77-05BF-4562-9A1A-AEE0531B59C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{417B5C77-05BF-4562-9A1A-AEE0531B59C1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A2E37A84-9331-48C7-8CCA-991528063087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A2E37A84-9331-48C7-8CCA-991528063087}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A2E37A84-9331-48C7-8CCA-991528063087}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A2E37A84-9331-48C7-8CCA-991528063087}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4A83DB6A-01BB-4B56-B38B-268444F22B1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4A83DB6A-01BB-4B56-B38B-268444F22B1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A83DB6A-01BB-4B56-B38B-268444F22B1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A83DB6A-01BB-4B56-B38B-268444F22B1E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A7AD8A07-C9C0-480B-A96B-2D03ACD57060}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A7AD8A07-C9C0-480B-A96B-2D03ACD57060}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A7AD8A07-C9C0-480B-A96B-2D03ACD57060}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A7AD8A07-C9C0-480B-A96B-2D03ACD57060}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{34720C2D-09AD-41F4-B7CC-D703D9F24EDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{34720C2D-09AD-41F4-B7CC-D703D9F24EDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{34720C2D-09AD-41F4-B7CC-D703D9F24EDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{34720C2D-09AD-41F4-B7CC-D703D9F24EDD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3AADD521-AFE4-4615-A0A3-2E89FE7E8559}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
3
GerstITS.Examples.sln.DotSettings
Normal file
3
GerstITS.Examples.sln.DotSettings
Normal file
@@ -0,0 +1,3 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gerst/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -0,0 +1,17 @@
|
||||
using GerstITS.Web.Rest.WebClients;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace GerstITS.Examples.WebClients.Examples.Api.Configurations
|
||||
{
|
||||
internal class ExampleApiClientConfiguration : RestWebServiceConfigurationBase
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public ExampleApiClientConfiguration(IConfiguration configuration)
|
||||
: base(configuration)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
27
GerstITS.WebClients.Example.Api/Contracts/ICountry.cs
Normal file
27
GerstITS.WebClients.Example.Api/Contracts/ICountry.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using GerstITS.Web.WebClients;
|
||||
|
||||
namespace GerstITS.Examples.WebClients.Examples.Api
|
||||
{
|
||||
public interface ICountry : IWebService
|
||||
{
|
||||
[WebMethod(WebMethods.Get),
|
||||
ResourceUrl("Country/{id}")]
|
||||
Country Get(int id);
|
||||
|
||||
[WebMethod(WebMethods.Get),
|
||||
ResourceUrl("Country/Search")]
|
||||
SearchResult<Country> Search(SearchCriteria criteria);
|
||||
|
||||
[WebMethod(WebMethods.Post),
|
||||
ResourceUrl("Country")]
|
||||
Country Create(Country model);
|
||||
|
||||
[WebMethod(WebMethods.Put),
|
||||
ResourceUrl("Country")]
|
||||
void Update(Country model);
|
||||
|
||||
[WebMethod(WebMethods.Delete),
|
||||
ResourceUrl("Country/{id}")]
|
||||
void Delete(int id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace GerstITS.Examples.WebClients.Examples.Api
|
||||
{
|
||||
public class Country
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace GerstITS.Examples.WebClients.Examples.Api
|
||||
{
|
||||
public class SearchCriteria
|
||||
{
|
||||
#region Properties
|
||||
|
||||
internal int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public int? Skip { get; set; }
|
||||
public int? Take { get; set; }
|
||||
|
||||
public string SortBy { get; set; }
|
||||
public SortingDirections SortDirection { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GerstITS.Examples.WebClients.Examples.Api
|
||||
{
|
||||
public class SearchResult<TItem>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
public int TotalCount { get; set; }
|
||||
public IEnumerable<TItem> Result { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public SearchResult()
|
||||
{
|
||||
Result = Array.Empty<TItem>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace GerstITS.Examples.WebClients.Examples.Api
|
||||
{
|
||||
public enum SortingDirections
|
||||
{
|
||||
Ascending = 0,
|
||||
Descending
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using GerstITS.Examples.WebClients.Examples.Api.Configurations;
|
||||
using GerstITS.Web.Rest.WebClients;
|
||||
|
||||
namespace GerstITS.Examples.WebClients.Examples.Api.CreationRules
|
||||
{
|
||||
internal sealed class ExampleApiClientCreatingRule : RestApiClientCreationRuleBase<ExampleApiClientConfiguration>
|
||||
{
|
||||
#region Properties
|
||||
|
||||
protected override Type[] SupportedTypes => new[] { typeof(ICountry) };
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ExampleApiClientCreatingRule(ExampleApiClientConfiguration configuration,
|
||||
Func<IRestWebServiceConfiguration, IRestWebServiceClient> restWebServiceClientFactory)
|
||||
: base(configuration, restWebServiceClientFactory)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Company>ITSCare GbR</Company>
|
||||
<Authors>ITSCare GbR</Authors>
|
||||
<Copyright>Copyright © ITSCare GbR 2021</Copyright>
|
||||
<Product>ITSCare GbR Example WebClient</Product>
|
||||
<Version>0.0.0.0</Version>
|
||||
<AssemblyVersion>0.0.0.0</AssemblyVersion>
|
||||
<AssemblyInformationalVersion>0.0.0.0</AssemblyInformationalVersion>
|
||||
<FileVersion>0.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GerstITS.IoC" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.IoC.DotNetCore" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.System" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Web" Version="2021.6.17" />
|
||||
<PackageReference Include="GerstITS.Web.Rest" Version="2021.6.17" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Module.Configurations.cs">
|
||||
<DependentUpon>Module.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Module.CreationRules.cs">
|
||||
<DependentUpon>Module.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,3 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=contracts/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=contracts_005Cserialization/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
17
GerstITS.WebClients.Example.Api/Module.Configurations.cs
Normal file
17
GerstITS.WebClients.Example.Api/Module.Configurations.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using GerstITS.Examples.WebClients.Examples.Api.Configurations;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.WebClients.Examples.Api
|
||||
{
|
||||
public sealed partial class Module
|
||||
{
|
||||
#region Methods
|
||||
|
||||
private static void RegisterConfigurations(IServiceCollection container)
|
||||
{
|
||||
container.AddSingleton<ExampleApiClientConfiguration>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
18
GerstITS.WebClients.Example.Api/Module.CreationRules.cs
Normal file
18
GerstITS.WebClients.Example.Api/Module.CreationRules.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using GerstITS.Examples.WebClients.Examples.Api.CreationRules;
|
||||
using GerstITS.Web.WebClients;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.WebClients.Examples.Api
|
||||
{
|
||||
public sealed partial class Module
|
||||
{
|
||||
#region Methods
|
||||
|
||||
private static void RegisterCreationRules(IServiceCollection container)
|
||||
{
|
||||
container.AddTransient<IWebServiceClientCreationRule, ExampleApiClientCreatingRule>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
18
GerstITS.WebClients.Example.Api/Module.cs
Normal file
18
GerstITS.WebClients.Example.Api/Module.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using GerstITS.IoC;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace GerstITS.Examples.WebClients.Examples.Api
|
||||
{
|
||||
public sealed partial class Module : IIoCModule<IServiceCollection>
|
||||
{
|
||||
#region IIoCModule
|
||||
|
||||
public void RegisterComponents(IServiceCollection container)
|
||||
{
|
||||
RegisterConfigurations(container);
|
||||
RegisterCreationRules(container);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
20
NuGet.Config
Normal file
20
NuGet.Config
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<config>
|
||||
<add key="repositoryPath" value="..\packages" />
|
||||
</config>
|
||||
<packageRestore>
|
||||
<add key="enabled" value="True" />
|
||||
<add key="automatic" value="True" />
|
||||
</packageRestore>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="Gerst ITS" value="https://packages.gerst-it.com/nuget/public/v3/index.json" />
|
||||
<add key="nuget.org - V2" value="https://www.nuget.org/api/v2/" />
|
||||
<add key="nuget.org - V3" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
<disabledPackageSources>
|
||||
</disabledPackageSources>
|
||||
<activePackageSource>
|
||||
</activePackageSource>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user