Добавления рест-проекта

This commit is contained in:
dasha 2023-04-01 22:06:59 +04:00
parent 18fc1b0e67
commit 289697c26d
7 changed files with 154 additions and 9 deletions

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HardwareShopBusinessLogic\HardwareShopBusinessLogic.csproj" />
<ProjectReference Include="..\HardwareShopContracts\HardwareShopContracts.csproj" />
<ProjectReference Include="..\HardwareShopDatabaseImplement\HardwareShopDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,58 @@
using HardwareShopBusinessLogic.BusinessLogics;
using HardwareShopBusinessLogic.BusinessLogics.Storekeeper;
using HardwareShopContracts.BuisnessLogicsContracts;
using HardwareShopContracts.BusinessLogicsContracts;
using HardwareShopContracts.StoragesContracts;
using HardwareShopDatabaseImplement.Implements;
using HardwareShopDatabaseImplement.Implements.Storekeeper;
using HardwareShopDatabaseImplement.Implements.Worker;
using Microsoft.OpenApi.Models;
using NLog.Extensions.Logging;
var builder = WebApplication.CreateBuilder(args);
builder.Logging.SetMinimumLevel(LogLevel.Information);
builder.Logging.AddNLog("nlog.config");
// Add services to the container.
builder.Services.AddTransient<IUserStorage, UserStorage>();
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
builder.Services.AddTransient<IGoodStorage, GoodStorage>();
builder.Services.AddTransient<IComponentStorage, ComponentStorage>();
builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
builder.Services.AddTransient<IBuildStorage, BuildStorage>();
builder.Services.AddTransient<ICommentStorage, CommentStorage>();
builder.Services.AddTransient<IUserLogic, UserLogic>();
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
builder.Services.AddTransient<IGoodLogic, GoodLogic>();
builder.Services.AddTransient<IComponentLogic, ComponentLogic>();
builder.Services.AddTransient<IPurchaseLogic, PurchaseLogic>();
builder.Services.AddTransient<IBuildLogic, BuildLogic>();
builder.Services.AddTransient<ICommentLogic, CommentLogic>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "HardwareShopRestApi", Version = "v1" });
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "HardwareShopRestApi v1"));
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:45313",
"sslPort": 44367
}
},
"profiles": {
"HardwareShopRestApi": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7205;http://localhost:5205",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" internalLogLevel="Info">
<targets>
<target xsi:type="File" name="tofile" fileName="log-${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>

View File

@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385 VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HardwareShopView", "HardwareShopView\HardwareShopView.csproj", "{14E5377A-FF6B-4FBA-B18A-5F6EB513123C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HardwareShopDataModels", "HardwareShopDataModels\HardwareShopDataModels.csproj", "{1589524F-918D-40B8-A44B-8C7FCABFD29A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HardwareShopDataModels", "HardwareShopDataModels\HardwareShopDataModels.csproj", "{1589524F-918D-40B8-A44B-8C7FCABFD29A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HardwareShopContracts", "HardwareShopContracts\HardwareShopContracts.csproj", "{91B12343-FCFB-4B7D-BBB8-C6A2C9D73996}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HardwareShopContracts", "HardwareShopContracts\HardwareShopContracts.csproj", "{91B12343-FCFB-4B7D-BBB8-C6A2C9D73996}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HardwareShopBusinessLogic", "HardwareShopBusinessLogic\HardwareShopBusinessLogic.csproj", "{3B96A73E-3385-4712-A7C4-9D67D424CE43}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HardwareShopBusinessLogic", "HardwareShopBusinessLogic\HardwareShopBusinessLogic.csproj", "{3B96A73E-3385-4712-A7C4-9D67D424CE43}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HardwareShopDatabaseImplement", "HardwareShopDatabaseImplement\HardwareShopDatabaseImplement.csproj", "{1E5156F6-1F67-497C-A660-8AC61BC451BC}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HardwareShopDatabaseImplement", "HardwareShopDatabaseImplement\HardwareShopDatabaseImplement.csproj", "{1E5156F6-1F67-497C-A660-8AC61BC451BC}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HardwareShopRestApi", "HardwareShopRestApi\HardwareShopRestApi.csproj", "{623AF3E7-85DA-4DB7-BC0E-8D669CEE9402}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -19,10 +19,6 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{14E5377A-FF6B-4FBA-B18A-5F6EB513123C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14E5377A-FF6B-4FBA-B18A-5F6EB513123C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14E5377A-FF6B-4FBA-B18A-5F6EB513123C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{14E5377A-FF6B-4FBA-B18A-5F6EB513123C}.Release|Any CPU.Build.0 = Release|Any CPU
{1589524F-918D-40B8-A44B-8C7FCABFD29A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1589524F-918D-40B8-A44B-8C7FCABFD29A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1589524F-918D-40B8-A44B-8C7FCABFD29A}.Debug|Any CPU.Build.0 = Debug|Any CPU {1589524F-918D-40B8-A44B-8C7FCABFD29A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1589524F-918D-40B8-A44B-8C7FCABFD29A}.Release|Any CPU.ActiveCfg = Release|Any CPU {1589524F-918D-40B8-A44B-8C7FCABFD29A}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -39,6 +35,10 @@ Global
{1E5156F6-1F67-497C-A660-8AC61BC451BC}.Debug|Any CPU.Build.0 = Debug|Any CPU {1E5156F6-1F67-497C-A660-8AC61BC451BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E5156F6-1F67-497C-A660-8AC61BC451BC}.Release|Any CPU.ActiveCfg = Release|Any CPU {1E5156F6-1F67-497C-A660-8AC61BC451BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E5156F6-1F67-497C-A660-8AC61BC451BC}.Release|Any CPU.Build.0 = Release|Any CPU {1E5156F6-1F67-497C-A660-8AC61BC451BC}.Release|Any CPU.Build.0 = Release|Any CPU
{623AF3E7-85DA-4DB7-BC0E-8D669CEE9402}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{623AF3E7-85DA-4DB7-BC0E-8D669CEE9402}.Debug|Any CPU.Build.0 = Debug|Any CPU
{623AF3E7-85DA-4DB7-BC0E-8D669CEE9402}.Release|Any CPU.ActiveCfg = Release|Any CPU
{623AF3E7-85DA-4DB7-BC0E-8D669CEE9402}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE