From 00f4536d2c5a19a27f6aa797fb58106874717dfc Mon Sep 17 00:00:00 2001 From: Louwar Date: Thu, 23 Mar 2023 16:43:23 +0100 Subject: [PATCH] Update Config API --- Sources/API/API.csproj | 7 ++----- Sources/API/Program.cs | 11 +++++++++-- Sources/API/Properties/launchSettings.json | 16 +++++++++++----- Sources/API/appsettings.Development.json | 13 ++++++++----- Sources/API/appsettings.json | 15 +++++++++------ Sources/LeagueOfLegends.sln | 14 +++++++------- 6 files changed, 46 insertions(+), 30 deletions(-) diff --git a/Sources/API/API.csproj b/Sources/API/API.csproj index c4c81f2..864554d 100644 --- a/Sources/API/API.csproj +++ b/Sources/API/API.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -7,15 +7,12 @@ - - - + - diff --git a/Sources/API/Program.cs b/Sources/API/Program.cs index 89faac5..d98a361 100644 --- a/Sources/API/Program.cs +++ b/Sources/API/Program.cs @@ -1,17 +1,24 @@ +using EFlib; +using EFManager; +using Microsoft.EntityFrameworkCore; using Model; -using StubLib; var builder = WebApplication.CreateBuilder(args); -// Add services to the container. +var connectionString = builder.Configuration.GetConnectionString("SQLiteContext"); +builder.Services.AddDbContext(options => options.UseSqlite(connectionString), ServiceLifetime.Singleton); builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); +builder.Services.AddSingleton(); + var app = builder.Build(); +app?.Services?.GetService()?.Database.EnsureCreated(); + // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { diff --git a/Sources/API/Properties/launchSettings.json b/Sources/API/Properties/launchSettings.json index c49b876..5607748 100644 --- a/Sources/API/Properties/launchSettings.json +++ b/Sources/API/Properties/launchSettings.json @@ -4,8 +4,8 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:44020", - "sslPort": 44337 + "applicationUrl": "http://localhost:28574", + "sslPort": 44383 } }, "profiles": { @@ -14,7 +14,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:7175;http://localhost:5048", + "applicationUrl": "https://localhost:7281;http://localhost:5051", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -24,8 +24,14 @@ "launchBrowser": true, "launchUrl": "swagger", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "useSSL": true } } } diff --git a/Sources/API/appsettings.Development.json b/Sources/API/appsettings.Development.json index 0c208ae..8e0a1d5 100644 --- a/Sources/API/appsettings.Development.json +++ b/Sources/API/appsettings.Development.json @@ -1,8 +1,11 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "ConnectionStrings": { + "SQLiteContext": "Data Source=projet.dbloulou.db" } - } } diff --git a/Sources/API/appsettings.json b/Sources/API/appsettings.json index 10f68b8..490cb9c 100644 --- a/Sources/API/appsettings.json +++ b/Sources/API/appsettings.json @@ -1,9 +1,12 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "ConnectionStrings": { + "SQLiteContext": "Data Source=projet.dbloulou.db" + }, "AllowedHosts": "*" } diff --git a/Sources/LeagueOfLegends.sln b/Sources/LeagueOfLegends.sln index 85d2fef..1a03d30 100644 --- a/Sources/LeagueOfLegends.sln +++ b/Sources/LeagueOfLegends.sln @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared", "Shared\Shared.csproj", "{3B720C0C-53FE-4642-A2DB-87FD8634CD74}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API", "API\API.csproj", "{37E43647-A760-467F-A3C3-71E25149D1BF}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{3EADD82A-15CF-40CC-BF4F-82F5385676A5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestEF", "Tests\TestEF\TestEF.csproj", "{5DEC05D8-59AA-4DD9-AD53-07A08C1EC0EC}" @@ -35,7 +33,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleEF", "EntityFramewor EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTests", "ConsoleTests\ConsoleTests.csproj", "{2421A321-D552-421B-94A5-92B9C34678CA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApi", "ConsoleApi\ConsoleApi.csproj", "{B30F9603-22B5-46EE-B617-44C25C4A207E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApi", "ConsoleApi\ConsoleApi.csproj", "{B30F9603-22B5-46EE-B617-44C25C4A207E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "API\API.csproj", "{EE27B518-574C-4691-9A0A-AD83D73B2145}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -51,10 +51,6 @@ Global {3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Debug|Any CPU.Build.0 = Debug|Any CPU {3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Release|Any CPU.ActiveCfg = Release|Any CPU {3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Release|Any CPU.Build.0 = Release|Any CPU - {37E43647-A760-467F-A3C3-71E25149D1BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {37E43647-A760-467F-A3C3-71E25149D1BF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {37E43647-A760-467F-A3C3-71E25149D1BF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {37E43647-A760-467F-A3C3-71E25149D1BF}.Release|Any CPU.Build.0 = Release|Any CPU {5DEC05D8-59AA-4DD9-AD53-07A08C1EC0EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5DEC05D8-59AA-4DD9-AD53-07A08C1EC0EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {5DEC05D8-59AA-4DD9-AD53-07A08C1EC0EC}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -99,6 +95,10 @@ Global {B30F9603-22B5-46EE-B617-44C25C4A207E}.Debug|Any CPU.Build.0 = Debug|Any CPU {B30F9603-22B5-46EE-B617-44C25C4A207E}.Release|Any CPU.ActiveCfg = Release|Any CPU {B30F9603-22B5-46EE-B617-44C25C4A207E}.Release|Any CPU.Build.0 = Release|Any CPU + {EE27B518-574C-4691-9A0A-AD83D73B2145}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE27B518-574C-4691-9A0A-AD83D73B2145}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE27B518-574C-4691-9A0A-AD83D73B2145}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE27B518-574C-4691-9A0A-AD83D73B2145}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE