Добавление проекта RestApi.
This commit is contained in:
parent
e070505e85
commit
d5394c869f
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BlackmithWorkshopRestApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
45
BlacksmithWorkshop/BlackmithWorkshopRestApi/Program.cs
Normal file
45
BlacksmithWorkshop/BlackmithWorkshopRestApi/Program.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using BlacksmithWorkshopBusinessLogic.BusinessLogic;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopDatabaseImplement.Implements;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
builder.Logging.AddLog4Net("log4net.config");
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IManufactureStorage, ManufactureStorage>();
|
||||
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<IManufactureLogic, ManufactureLogic>();
|
||||
|
||||
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 = "BlacksmithWorkshopRestApi", 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", "BlacksmithWorkshopRestApi v1"));
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:22588",
|
||||
"sslPort": 44369
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"BlackmithWorkshopRestApi": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7272;http://localhost:5169",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
namespace BlackmithWorkshopRestApi
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
16
BlacksmithWorkshop/BlackmithWorkshopRestApi/log4net.config
Normal file
16
BlacksmithWorkshop/BlackmithWorkshopRestApi/log4net.config
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<log4net>
|
||||
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
|
||||
<file value="c:/temp/BlacksmithWorkshopResrApi.log" />
|
||||
<appendToFile value="true" />
|
||||
<maximumFileSize value="100KB" />
|
||||
<maxSizeRollBackups value="2" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="TRACE" />
|
||||
<appender-ref ref="RollingFile" />
|
||||
</root>
|
||||
</log4net>
|
@ -15,7 +15,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopListImple
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopFileImplement", "BlacksmithWorkshopFileImplement\BlacksmithWorkshopFileImplement.csproj", "{58737D93-9A12-4D07-BF3F-86AC512CE626}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopDatabaseImplement", "BlacksmithWorkshopDatabaseImplement\BlacksmithWorkshopDatabaseImplement.csproj", "{EE03BAE3-52EE-4E3B-8992-382D89E61E1A}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopDatabaseImplement", "BlacksmithWorkshopDatabaseImplement\BlacksmithWorkshopDatabaseImplement.csproj", "{EE03BAE3-52EE-4E3B-8992-382D89E61E1A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopRestApi", "BlackmithWorkshopRestApi\BlacksmithWorkshopRestApi.csproj", "{23DBD9A3-2107-44AB-8B87-6982BFD2E69A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -51,6 +53,10 @@ Global
|
||||
{EE03BAE3-52EE-4E3B-8992-382D89E61E1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EE03BAE3-52EE-4E3B-8992-382D89E61E1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EE03BAE3-52EE-4E3B-8992-382D89E61E1A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{23DBD9A3-2107-44AB-8B87-6982BFD2E69A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{23DBD9A3-2107-44AB-8B87-6982BFD2E69A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{23DBD9A3-2107-44AB-8B87-6982BFD2E69A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{23DBD9A3-2107-44AB-8B87-6982BFD2E69A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Loading…
Reference in New Issue
Block a user