ajout entityframework lib + webapi + lib model

EF
Maxence LANONE 2 years ago
parent b8df10dee8
commit 0f050d57a1

@ -5,7 +5,4 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\HelloWorldLib\HelloWorldLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,6 @@
namespace Model;
public class Class1
{
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -19,7 +19,4 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\HelloWorldLib\HelloWorldLib.csproj" />
</ItemGroup>
</Project>

@ -3,32 +3,38 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.810.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldLib", "HelloWorldLib\HelloWorldLib.csproj", "{48BBA997-E63D-48BB-BB2A-538457425F02}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C75DF644-C41F-4A08-8B69-C8554204AC72}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldApp", "HelloWorldApp\HelloWorldApp.csproj", "{21365B7E-4A1A-4C37-B140-A9D6FC7A7E50}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWordLib_UnitTests", "Tests\HelloWordLib_UnitTests\HelloWordLib_UnitTests.csproj", "{F9B12DFD-EF58-429F-9344-70DFC10EC6E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Trek12_API", "Trek12_API\Trek12_API.csproj", "{3BF053E1-44DF-4305-ACBA-21F7A053A514}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameWorkLib", "Trek12_Lib\EntityFrameWorkLib.csproj", "{E22E6061-91C0-4503-AFC8-8D01912D3AA0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{4BEFD382-A3A4-444E-973E-73F410F9CED4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{48BBA997-E63D-48BB-BB2A-538457425F02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48BBA997-E63D-48BB-BB2A-538457425F02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48BBA997-E63D-48BB-BB2A-538457425F02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48BBA997-E63D-48BB-BB2A-538457425F02}.Release|Any CPU.Build.0 = Release|Any CPU
{21365B7E-4A1A-4C37-B140-A9D6FC7A7E50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21365B7E-4A1A-4C37-B140-A9D6FC7A7E50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21365B7E-4A1A-4C37-B140-A9D6FC7A7E50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21365B7E-4A1A-4C37-B140-A9D6FC7A7E50}.Release|Any CPU.Build.0 = Release|Any CPU
{F9B12DFD-EF58-429F-9344-70DFC10EC6E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9B12DFD-EF58-429F-9344-70DFC10EC6E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9B12DFD-EF58-429F-9344-70DFC10EC6E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9B12DFD-EF58-429F-9344-70DFC10EC6E5}.Release|Any CPU.Build.0 = Release|Any CPU
{3BF053E1-44DF-4305-ACBA-21F7A053A514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3BF053E1-44DF-4305-ACBA-21F7A053A514}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BF053E1-44DF-4305-ACBA-21F7A053A514}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BF053E1-44DF-4305-ACBA-21F7A053A514}.Release|Any CPU.Build.0 = Release|Any CPU
{E22E6061-91C0-4503-AFC8-8D01912D3AA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E22E6061-91C0-4503-AFC8-8D01912D3AA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E22E6061-91C0-4503-AFC8-8D01912D3AA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E22E6061-91C0-4503-AFC8-8D01912D3AA0}.Release|Any CPU.Build.0 = Release|Any CPU
{4BEFD382-A3A4-444E-973E-73F410F9CED4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4BEFD382-A3A4-444E-973E-73F410F9CED4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BEFD382-A3A4-444E-973E-73F410F9CED4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BEFD382-A3A4-444E-973E-73F410F9CED4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace Trek12_API.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();
}
}

@ -0,0 +1,26 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

@ -0,0 +1,30 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:23493",
"sslPort": 44311
}
},
"profiles": {
"Trek12_API": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7289;http://localhost:5195",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -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,13 @@
namespace Trek12_API;
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,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

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

@ -0,0 +1,6 @@
namespace Trek12_Lib;
public class Class1
{
}

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>Trek12_Lib</AssemblyName>
</PropertyGroup>
</Project>
Loading…
Cancel
Save