Initialize Core Model

This commit is contained in:
MaxchilKH 2020-05-22 08:59:16 +02:00
parent b6c95ba21a
commit f9da73ea76
23 changed files with 330 additions and 17 deletions

View File

@ -1,7 +1,9 @@
version: "3.8"
version: "3.3"
services:
internship.api:
image: internship.api:latest
build: ../src/Internship.Api
ports:
- 8080:80

36
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,36 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Internship.Api/bin/Debug/netcoreapp3.1/Internship.Api.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Internship.Api",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}

42
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,42 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/Internship.Api/Internship.Api.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/Internship.Api/Internship.Api.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/src/Internship.Api/Internship.Api.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -3,6 +3,20 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A43DB15B-657C-4E02-BC1B-2670DD34D9E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Internship.Api", "src\Internship.Api\Internship.Api.csproj", "{2C72839D-2E0B-4794-9324-3E9E622251E3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Internship.Repository", "src\Internship.Repository\Internship.Repository.csproj", "{A4697640-0746-4720-9B20-923763612F1A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Internship.Core", "src\Internship.Core\Internship.Core.csproj", "{2C395A11-E3A2-4454-95A1-82A3EAE791EC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{69F62FEE-6768-4B47-9295-4EF5E8E30BEA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Internship.Api.Test", "test\Internship.Api.Test\Internship.Api.Test.csproj", "{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Internship.Core.Tests", "test\Internship.Core.Tests\Internship.Core.Tests.csproj", "{748544B4-CBDA-4123-9BD9-499F6C90567F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,4 +29,73 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Debug|x64.ActiveCfg = Debug|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Debug|x64.Build.0 = Debug|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Debug|x86.ActiveCfg = Debug|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Debug|x86.Build.0 = Debug|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Release|Any CPU.Build.0 = Release|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Release|x64.ActiveCfg = Release|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Release|x64.Build.0 = Release|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Release|x86.ActiveCfg = Release|Any CPU
{2C72839D-2E0B-4794-9324-3E9E622251E3}.Release|x86.Build.0 = Release|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Debug|x64.ActiveCfg = Debug|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Debug|x64.Build.0 = Debug|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Debug|x86.ActiveCfg = Debug|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Debug|x86.Build.0 = Debug|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Release|Any CPU.Build.0 = Release|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Release|x64.ActiveCfg = Release|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Release|x64.Build.0 = Release|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Release|x86.ActiveCfg = Release|Any CPU
{A4697640-0746-4720-9B20-923763612F1A}.Release|x86.Build.0 = Release|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Debug|x64.ActiveCfg = Debug|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Debug|x64.Build.0 = Debug|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Debug|x86.ActiveCfg = Debug|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Debug|x86.Build.0 = Debug|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Release|Any CPU.Build.0 = Release|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Release|x64.ActiveCfg = Release|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Release|x64.Build.0 = Release|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Release|x86.ActiveCfg = Release|Any CPU
{2C395A11-E3A2-4454-95A1-82A3EAE791EC}.Release|x86.Build.0 = Release|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Debug|x64.ActiveCfg = Debug|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Debug|x64.Build.0 = Debug|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Debug|x86.ActiveCfg = Debug|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Debug|x86.Build.0 = Debug|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Release|Any CPU.Build.0 = Release|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Release|x64.ActiveCfg = Release|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Release|x64.Build.0 = Release|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Release|x86.ActiveCfg = Release|Any CPU
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE}.Release|x86.Build.0 = Release|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Debug|x64.ActiveCfg = Debug|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Debug|x64.Build.0 = Debug|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Debug|x86.ActiveCfg = Debug|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Debug|x86.Build.0 = Debug|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Release|Any CPU.Build.0 = Release|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Release|x64.ActiveCfg = Release|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Release|x64.Build.0 = Release|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Release|x86.ActiveCfg = Release|Any CPU
{748544B4-CBDA-4123-9BD9-499F6C90567F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2C72839D-2E0B-4794-9324-3E9E622251E3} = {A43DB15B-657C-4E02-BC1B-2670DD34D9E0}
{A4697640-0746-4720-9B20-923763612F1A} = {A43DB15B-657C-4E02-BC1B-2670DD34D9E0}
{2C395A11-E3A2-4454-95A1-82A3EAE791EC} = {A43DB15B-657C-4E02-BC1B-2670DD34D9E0}
{90365B6B-B2C6-49D9-84F7-F806B06C1AFE} = {69F62FEE-6768-4B47-9295-4EF5E8E30BEA}
{748544B4-CBDA-4123-9BD9-499F6C90567F} = {69F62FEE-6768-4B47-9295-4EF5E8E30BEA}
EndGlobalSection
EndGlobal

View File

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Serilog;
namespace Internship.Api.Controllers
{
@ -27,6 +28,9 @@ namespace Internship.Api.Controllers
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
Log.Warning("Randomly generated number was: {Rng}", rng);
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),

View File

@ -13,4 +13,4 @@ RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "InternshipSystem.dll"]
ENTRYPOINT ["dotnet", "./Internship.Api.dll"]

View File

@ -1,8 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<!-- <GenerateDocumentationFile>true</GenerateDocumentationFile>-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.3.2" />
</ItemGroup>
</Project>

View File

@ -6,6 +6,9 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Events;
using Serilog.Formatting.Compact;
namespace Internship.Api
{
@ -18,10 +21,12 @@ namespace Internship.Api
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseStartup<Startup>();
});
.UseSerilog((context, configuration) =>
configuration
.Enrich.FromLogContext()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.WriteTo.Console())
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
}
}

View File

@ -10,33 +10,34 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
namespace Internship.Api
{
public class Startup
{
public Startup(IConfiguration configuration)
{
private IConfiguration Configuration { get; }
public Startup(IConfiguration configuration) =>
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) =>
services
.AddSwaggerGen(options =>
options.SwaggerDoc("v1", new OpenApiInfo {Title = "InternshipSystem Api", Version = "v1"}))
.AddControllers()
;
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app
.UseSwagger()
.UseSwaggerUI(options => options.SwaggerEndpoint("/swagger/v1/swagger.json", "InternshipSystem Api"))
.UseHttpsRedirection()
.UseRouting()
.UseAuthorization()

View File

@ -0,0 +1,6 @@
namespace Internship.Core
{
public class BranchOffice
{
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Internship.Core
{
public class Edition
{
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Internship.Core
{
public class Intern
{
public string AlbumNumber { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
}
}

View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,11 @@
namespace Internship.Core
{
public class Internship
{
public Intern Intern { get; set; }
public Edition Edition { get; set; }
public Report Report { get; set; }
public BranchOffice BranchOffice { get; set; }
public InternshipProgram Program { get; set; }
}
}

View File

@ -0,0 +1,6 @@
namespace Internship.Core
{
public class InternshipProgram
{
}
}

View File

@ -0,0 +1,6 @@
namespace Internship.Core
{
public class Report
{
}
}

View File

@ -1,7 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Machine.Fakes.FakeItEasy" Version="2.11.0" />
<PackageReference Include="Machine.Specifications" Version="1.0.0" />
<PackageReference Include="Machine.Specifications.Runner.VisualStudio" Version="2.10.1" />
<PackageReference Include="Machine.Specifications.Should" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,6 @@
using System;
using Machine.Specifications;
namespace Internship.Api.Test
{
}

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Machine.Fakes.FakeItEasy" Version="2.11.0" />
<PackageReference Include="Machine.Specifications" Version="1.0.0" />
<PackageReference Include="Machine.Specifications.Runner.VisualStudio" Version="2.10.1" />
<PackageReference Include="Machine.Specifications.Should" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Internship.Core\Internship.Core.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,17 @@
using System;
using Machine.Specifications;
// ReSharper disable InconsistentNaming
namespace Internship.Core.Tests
{
[Subject(typeof(Internship))]
class When_doing_something
{
Establish context = () => { };
Because of = () => { };
It should_shit_a_brick = () =>
false.ShouldBeTrue();
}
}