From 475de804eb05f518e32626b4ab88fccbcfe5c977 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 17:27:56 +0100 Subject: [PATCH 01/78] =?UTF-8?q?Ajout=20du=20dockerfile=20et=20du=20d?= =?UTF-8?q?=C3=A9ploiement=20de=20l'api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 30 ++++++++++++++++++++++- API_SQLuedo/DbContextLib/UserDbContext.cs | 4 +-- docker/Dockerfile | 25 +++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 docker/Dockerfile diff --git a/.drone.yml b/.drone.yml index 95ed74b..574a6ad 100644 --- a/.drone.yml +++ b/.drone.yml @@ -56,4 +56,32 @@ steps: from_secret: db_password CODEFIRST_CLIENTDRONE_ENV_POSTGRES_DB: from_secret: db_database - ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu \ No newline at end of file + ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu + depends_on: [ tests ] + + # Build and push API image + - name: api-image-build-and-push + image: plugins/docker + settings: + dockerfile: docker/Dockerfile + context: API_SQLuedo/ + registry: hub.codefirst.iut.uca.fr + repo: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo + username: + from_secret: secret_registry_username + password: + from_secret: secret_registry_password + depends_on: [ deploy-sqluedo-db ] + + # Deploy API + - name: deploy-api-from-image + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest + environment: + IMAGENAME: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo + CONTAINERNAME: api-sqluedo + COMMAND: create + OVERWRITE: true + CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: + from_secret: connection_string + ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu + depends_on: [ api-image-build-and-push ] \ No newline at end of file diff --git a/API_SQLuedo/DbContextLib/UserDbContext.cs b/API_SQLuedo/DbContextLib/UserDbContext.cs index 8c84706..b220b88 100644 --- a/API_SQLuedo/DbContextLib/UserDbContext.cs +++ b/API_SQLuedo/DbContextLib/UserDbContext.cs @@ -26,8 +26,8 @@ namespace DbContextLib base.OnConfiguring(optionsBuilder); if (!optionsBuilder.IsConfigured) { - //optionsBuilder.UseNpgsql(Environment.GetEnvironmentVariable("CONNECTION_STRING", EnvironmentVariableTarget.Process)); - optionsBuilder.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=motdepasse"); + optionsBuilder.UseNpgsql(Environment.GetEnvironmentVariable("CONNECTION_STRING", EnvironmentVariableTarget.Process)); + //optionsBuilder.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=motdepasse"); } } diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..c88caff --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,25 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +WORKDIR /api +EXPOSE 5000 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src +COPY ["../API_SQLuedo/API/API.csproj", "API_SQLuedo/"] + +# Restore dependencies +RUN dotnet restore "API_SQLuedo/API/API.csproj" + +# Copy the rest of the files +COPY "../API_SQLuedo/API/." "API_SQLuedo/" +WORKDIR "/src/API_SQLuedo" +RUN dotnet build "API.csproj" -c Release -o /app/build + +# Publish the application +FROM build AS publish +RUN dotnet publish "API.csproj" -c Release -o /app/publish + +# Final image +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "API.dll"] \ No newline at end of file From 2352ebc5b5d35a9f7d63b673dcfb7690efc7f3f9 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:12:33 +0100 Subject: [PATCH 02/78] Ajustement du chemin vers le fichier --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c88caff..56cbcad 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,13 +4,13 @@ EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src -COPY ["../API_SQLuedo/API/API.csproj", "API_SQLuedo/"] +COPY ["API_SQLuedo/API/API.csproj", "API_SQLuedo/"] # Restore dependencies RUN dotnet restore "API_SQLuedo/API/API.csproj" # Copy the rest of the files -COPY "../API_SQLuedo/API/." "API_SQLuedo/" +COPY ["API_SQLuedo/API/." "API_SQLuedo/"] WORKDIR "/src/API_SQLuedo" RUN dotnet build "API.csproj" -c Release -o /app/build From 9a834c8300dd7bf48b411bb9395ef0a39fbed33c Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:14:27 +0100 Subject: [PATCH 03/78] Debug du chemin --- docker/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 56cbcad..7fc3f48 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,6 +4,8 @@ EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src +RUN cd API_SQLuedo/API +RUN ls COPY ["API_SQLuedo/API/API.csproj", "API_SQLuedo/"] # Restore dependencies From 7fbe9d425c701afb285d4fe2348aeba066a7920f Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:15:38 +0100 Subject: [PATCH 04/78] Debug du chemin --- docker/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 7fc3f48..db40acf 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,7 +4,6 @@ EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src -RUN cd API_SQLuedo/API RUN ls COPY ["API_SQLuedo/API/API.csproj", "API_SQLuedo/"] From 8734e08051aaed3766c9c338dca6bc581915d5e8 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:18:04 +0100 Subject: [PATCH 05/78] Debug du chemin vers le csproj --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index db40acf..7bab4d4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -23,4 +23,4 @@ RUN dotnet publish "API.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "API.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "API.dll"] From 156bf23d6b4fd0f54250c6fdbd9461666c21978a Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:19:48 +0100 Subject: [PATCH 06/78] Debug du chemin vers le csproj --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 7bab4d4..c317e66 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,6 +4,7 @@ EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src +RUN pwd RUN ls COPY ["API_SQLuedo/API/API.csproj", "API_SQLuedo/"] From 20b94d67bba170e687858080422440fa574f81ec Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:24:03 +0100 Subject: [PATCH 07/78] Debug du chemin vers le csproj --- .drone.yml | 1 - docker/Dockerfile | 1 - 2 files changed, 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 574a6ad..6a44030 100644 --- a/.drone.yml +++ b/.drone.yml @@ -71,7 +71,6 @@ steps: from_secret: secret_registry_username password: from_secret: secret_registry_password - depends_on: [ deploy-sqluedo-db ] # Deploy API - name: deploy-api-from-image diff --git a/docker/Dockerfile b/docker/Dockerfile index c317e66..b92ae87 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,7 +3,6 @@ WORKDIR /api EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build -WORKDIR /src RUN pwd RUN ls COPY ["API_SQLuedo/API/API.csproj", "API_SQLuedo/"] From 5ea246fb4cb164abcc5d414885836d50f7534343 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:25:28 +0100 Subject: [PATCH 08/78] Debug du chemin vers le csproj --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 6a44030..66e12a5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -64,7 +64,7 @@ steps: image: plugins/docker settings: dockerfile: docker/Dockerfile - context: API_SQLuedo/ + context: . registry: hub.codefirst.iut.uca.fr repo: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo username: From fd1826d324510b6da6835db651eda09d4cda5281 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:28:52 +0100 Subject: [PATCH 09/78] Debug du chemin vers le csproj --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index b92ae87..e801b45 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,7 +5,7 @@ EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build RUN pwd RUN ls -COPY ["API_SQLuedo/API/API.csproj", "API_SQLuedo/"] +COPY API_SQLuedo/API/API.csproj API_SQLuedo/ # Restore dependencies RUN dotnet restore "API_SQLuedo/API/API.csproj" From 92d7f0556ca67f464d7bf180389aabb0184b11be Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:30:26 +0100 Subject: [PATCH 10/78] Debug du chemin vers le csproj --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index e801b45..4787dcf 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,11 +1,11 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +COPY API_SQLuedo/API/API.csproj /api WORKDIR /api EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build RUN pwd RUN ls -COPY API_SQLuedo/API/API.csproj API_SQLuedo/ # Restore dependencies RUN dotnet restore "API_SQLuedo/API/API.csproj" From f6624b4b5b68132bfc126f4ae59d2dd5bca8478c Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:31:55 +0100 Subject: [PATCH 11/78] Debug du chemin vers le csproj --- docker/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4787dcf..ca638f1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,11 +1,9 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base -COPY API_SQLuedo/API/API.csproj /api +COPY API_SQLuedo/API/API.csproj /api/ WORKDIR /api EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build -RUN pwd -RUN ls # Restore dependencies RUN dotnet restore "API_SQLuedo/API/API.csproj" From 8a9cd73a1ff6f290d49b533630a2ef1fcbefd76b Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:34:12 +0100 Subject: [PATCH 12/78] Debug du chemin vers la copie des fichiers --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ca638f1..40ae209 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,10 +6,10 @@ EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build # Restore dependencies -RUN dotnet restore "API_SQLuedo/API/API.csproj" +RUN dotnet restore api/API.csproj # Copy the rest of the files -COPY ["API_SQLuedo/API/." "API_SQLuedo/"] +COPY API_SQLuedo/API/. api/ WORKDIR "/src/API_SQLuedo" RUN dotnet build "API.csproj" -c Release -o /app/build From 1b1ff43d339df2e09fa9ca861e51c7ee652342ae Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:34:57 +0100 Subject: [PATCH 13/78] Debug du chemin vers l'api --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 40ae209..4de477e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,7 +6,7 @@ EXPOSE 5000 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build # Restore dependencies -RUN dotnet restore api/API.csproj +RUN dotnet restore API.csproj # Copy the rest of the files COPY API_SQLuedo/API/. api/ From f00adb968e65decc44dcf3ddf2e8e0065525a337 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:40:41 +0100 Subject: [PATCH 14/78] Debug du chemin vers l'api --- docker/Dockerfile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4de477e..48d3ee6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,24 +1,24 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base -COPY API_SQLuedo/API/API.csproj /api/ -WORKDIR /api -EXPOSE 5000 - FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src +COPY API_SQLuedo/API/API.csproj . # Restore dependencies RUN dotnet restore API.csproj # Copy the rest of the files -COPY API_SQLuedo/API/. api/ -WORKDIR "/src/API_SQLuedo" -RUN dotnet build "API.csproj" -c Release -o /app/build +COPY API_SQLuedo/API/ . + +# Build the application +RUN dotnet build API.csproj -c Release -o /app/build # Publish the application FROM build AS publish -RUN dotnet publish "API.csproj" -c Release -o /app/publish +RUN dotnet publish API.csproj -c Release -o /app/publish + # Final image -FROM base AS final -WORKDIR /app +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +WORKDIR /api +EXPOSE 5000 COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "API.dll"] From 5ffdb9157326c2765cc18395c8d39ebdd7326837 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:50:47 +0100 Subject: [PATCH 15/78] Ajout dockerignore pour tout copier avant le restore --- docker/.dockerignore | 1 + docker/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 docker/.dockerignore diff --git a/docker/.dockerignore b/docker/.dockerignore new file mode 100644 index 0000000..ce8f61a --- /dev/null +++ b/docker/.dockerignore @@ -0,0 +1 @@ +**/*Test*.csproj \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 48d3ee6..65e0920 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src -COPY API_SQLuedo/API/API.csproj . +COPY API_SQLuedo/**/*.csproj . # Restore dependencies RUN dotnet restore API.csproj From dce7d39ca4350b14d38109e5836267121a427227 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:51:36 +0100 Subject: [PATCH 16/78] Debug du chemin de copie --- docker/Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 65e0920..bcd56bc 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,13 +1,10 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src -COPY API_SQLuedo/**/*.csproj . +COPY API_SQLuedo/**/*.csproj ./ # Restore dependencies RUN dotnet restore API.csproj -# Copy the rest of the files -COPY API_SQLuedo/API/ . - # Build the application RUN dotnet build API.csproj -c Release -o /app/build From 388b6edcfb22675ec02d2fb47e5fed9f5a02968e Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:52:59 +0100 Subject: [PATCH 17/78] Debug du chemin de copie --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index bcd56bc..ee9d0a7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src -COPY API_SQLuedo/**/*.csproj ./ +COPY API_SQLuedo/ ./ # Restore dependencies RUN dotnet restore API.csproj From b2cf52502c43ca0d1158cbfccf0ee5091bc199ea Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:54:18 +0100 Subject: [PATCH 18/78] Ajout du bon chemin vers le csproj --- docker/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ee9d0a7..ee61f75 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,14 +3,14 @@ WORKDIR /src COPY API_SQLuedo/ ./ # Restore dependencies -RUN dotnet restore API.csproj +RUN dotnet restore API/API.csproj # Build the application -RUN dotnet build API.csproj -c Release -o /app/build +RUN dotnet build API/API.csproj -c Release -o /app/build # Publish the application FROM build AS publish -RUN dotnet publish API.csproj -c Release -o /app/publish +RUN dotnet publish API/API.csproj -c Release -o /app/publish # Final image From 2b149e3613ded37f02e5c3104c4b2134fcc3e774 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:56:50 +0100 Subject: [PATCH 19/78] Ajout du bon chemin vers le secret --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 66e12a5..e032292 100644 --- a/.drone.yml +++ b/.drone.yml @@ -81,6 +81,6 @@ steps: COMMAND: create OVERWRITE: true CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: - from_secret: connection_string + from_secret: connection_string ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu depends_on: [ api-image-build-and-push ] \ No newline at end of file From 0c8003c4a3cc80d838b70c9cc9ffc7bf79516326 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 18:59:54 +0100 Subject: [PATCH 20/78] =?UTF-8?q?D=C3=A9placement=20du=20fichier=20dll=20l?= =?UTF-8?q?'ex=C3=A9cuter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ee61f75..2b6b253 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -18,4 +18,4 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base WORKDIR /api EXPOSE 5000 COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "API.dll"] +ENTRYPOINT ["dotnet", "./API.dll"] From 3008b02f447d79a5d6efa7245475a07423ce00aa Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 19:05:36 +0100 Subject: [PATCH 21/78] Ajout du bon chemin pour la commande dotnet et suppression du build --- docker/Dockerfile | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 2b6b253..293386a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,21 +1,16 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build -WORKDIR /src +WORKDIR /app COPY API_SQLuedo/ ./ # Restore dependencies RUN dotnet restore API/API.csproj -# Build the application -RUN dotnet build API/API.csproj -c Release -o /app/build - # Publish the application -FROM build AS publish RUN dotnet publish API/API.csproj -c Release -o /app/publish # Final image FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base -WORKDIR /api -EXPOSE 5000 -COPY --from=publish /app/publish . +WORKDIR /app +COPY --from=build /app/publish . ENTRYPOINT ["dotnet", "./API.dll"] From 284d380e9924b0a373c469a9d6f52426c776a13c Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 19:13:35 +0100 Subject: [PATCH 22/78] Debug en supprimant la commande shell --- docker/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 293386a..07394d0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -13,4 +13,3 @@ RUN dotnet publish API/API.csproj -c Release -o /app/publish FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base WORKDIR /app COPY --from=build /app/publish . -ENTRYPOINT ["dotnet", "./API.dll"] From b8ade38df4afc1eba34fa1b6015a3112fc9ab29b Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 19:17:14 +0100 Subject: [PATCH 23/78] Reformat du code et ajout entrypoint --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 07394d0..41a793a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,8 +8,8 @@ RUN dotnet restore API/API.csproj # Publish the application RUN dotnet publish API/API.csproj -c Release -o /app/publish - # Final image FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base WORKDIR /app COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "./API.dll"] From bba3bdffefe4bfe2e1af3f3793a5a4031aade9c9 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 19:17:56 +0100 Subject: [PATCH 24/78] Refomat du code --- .drone.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index e032292..c8125e1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,11 +20,11 @@ steps: - cd API_SQLuedo/ - dotnet restore API_SQLuedo.sln - dotnet test API_SQLuedo.sln -c Release --no-build --no-restore - depends_on: [ build ] + depends_on: [build] - name: code-inspection image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet8 - secrets: [ SECRET_SONAR_LOGIN ] + secrets: [SECRET_SONAR_LOGIN] environment: sonar_host: https://codefirst.iut.uca.fr/sonar/ sonar_token: @@ -40,7 +40,7 @@ steps: - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - dotnet publish API_SQLuedo.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - dotnet sonarscanner end /d:sonar.login=$${sonar_token} - depends_on: [ build ] + depends_on: [build] - name: deploy-sqluedo-db image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest @@ -57,7 +57,7 @@ steps: CODEFIRST_CLIENTDRONE_ENV_POSTGRES_DB: from_secret: db_database ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu - depends_on: [ tests ] + depends_on: [tests] # Build and push API image - name: api-image-build-and-push @@ -83,4 +83,4 @@ steps: CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: from_secret: connection_string ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu - depends_on: [ api-image-build-and-push ] \ No newline at end of file + depends_on: [api-image-build-and-push] From 30c9c158e069d9baf3dca3ad81c69ca4cffa65c6 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 19:27:31 +0100 Subject: [PATCH 25/78] Suppression espace blanc --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index c8125e1..a09b58e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -83,4 +83,4 @@ steps: CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: from_secret: connection_string ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu - depends_on: [api-image-build-and-push] + depends_on: [api-image-build-and-push] \ No newline at end of file From cdc73c5716bb57d13a30727f82cf90c57fa1bb03 Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 19:51:55 +0100 Subject: [PATCH 26/78] Changement nom du container --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index a09b58e..7491ca7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -77,7 +77,7 @@ steps: image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: IMAGENAME: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo - CONTAINERNAME: api-sqluedo + CONTAINERNAME: sqluedo-api COMMAND: create OVERWRITE: true CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: From b39257855e2888a55cc4f1842b20d3fb8d8b0f6e Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 19:53:55 +0100 Subject: [PATCH 27/78] Suppression du create --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 7491ca7..2b14c8d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -78,7 +78,6 @@ steps: environment: IMAGENAME: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo CONTAINERNAME: sqluedo-api - COMMAND: create OVERWRITE: true CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: from_secret: connection_string From 77f28e7e1a9e72734a3c72b02271377c832f5d3f Mon Sep 17 00:00:00 2001 From: clchieu Date: Wed, 27 Mar 2024 19:55:47 +0100 Subject: [PATCH 28/78] =?UTF-8?q?Ajout=20du=20create=20=C3=A0=20la=20fin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 2b14c8d..eb0ae36 100644 --- a/.drone.yml +++ b/.drone.yml @@ -82,4 +82,5 @@ steps: CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: from_secret: connection_string ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu + COMMAND: create depends_on: [api-image-build-and-push] \ No newline at end of file From d42f7acb9f67771214dc9092bdf199a14e5a7a65 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 09:42:55 +0100 Subject: [PATCH 29/78] Reproduction de la doc --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index eb0ae36..7491ca7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -78,9 +78,9 @@ steps: environment: IMAGENAME: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo CONTAINERNAME: sqluedo-api + COMMAND: create OVERWRITE: true CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: from_secret: connection_string ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu - COMMAND: create depends_on: [api-image-build-and-push] \ No newline at end of file From 73e1aed1a08b8ece86fff89a43a720c3b957a774 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 10:03:48 +0100 Subject: [PATCH 30/78] Modification de l'image --- .drone.yml | 4 ++-- API_SQLuedo/.dockerignore | 30 ++++++++++++++++++++++++++++++ API_SQLuedo/API/Dockerfile | 30 ++++++++++++++++++++++++++++++ docker/.dockerignore | 1 - docker/Dockerfile | 15 --------------- 5 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 API_SQLuedo/.dockerignore create mode 100644 API_SQLuedo/API/Dockerfile delete mode 100644 docker/.dockerignore delete mode 100644 docker/Dockerfile diff --git a/.drone.yml b/.drone.yml index 7491ca7..cbb0b9e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -63,8 +63,8 @@ steps: - name: api-image-build-and-push image: plugins/docker settings: - dockerfile: docker/Dockerfile - context: . + dockerfile: API_SQLuedo/API/Dockerfile + context: API_SQLuedo/ registry: hub.codefirst.iut.uca.fr repo: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo username: diff --git a/API_SQLuedo/.dockerignore b/API_SQLuedo/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/API_SQLuedo/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/API_SQLuedo/API/Dockerfile b/API_SQLuedo/API/Dockerfile new file mode 100644 index 0000000..e2db675 --- /dev/null +++ b/API_SQLuedo/API/Dockerfile @@ -0,0 +1,30 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER app +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["API/API.csproj", "API/"] +COPY ["DbContextLib/DbContextLib.csproj", "DbContextLib/"] +COPY ["EntityFramework/Entities.csproj", "EntityFramework/"] +COPY ["Dto/Dto.csproj", "Dto/"] +COPY ["DbDataManager/DbDataManager.csproj", "DbDataManager/"] +COPY ["Model/Model.csproj", "Model/"] +COPY ["Shared/Shared.csproj", "Shared/"] +COPY ["StubbedContextLib/StubbedContextLib.csproj", "StubbedContextLib/"] +RUN dotnet restore "./API/./API.csproj" +COPY . . +WORKDIR "/src/API" +RUN dotnet build "./API.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "API.dll"] \ No newline at end of file diff --git a/docker/.dockerignore b/docker/.dockerignore deleted file mode 100644 index ce8f61a..0000000 --- a/docker/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -**/*Test*.csproj \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 41a793a..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build -WORKDIR /app -COPY API_SQLuedo/ ./ - -# Restore dependencies -RUN dotnet restore API/API.csproj - -# Publish the application -RUN dotnet publish API/API.csproj -c Release -o /app/publish - -# Final image -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base -WORKDIR /app -COPY --from=build /app/publish . -ENTRYPOINT ["dotnet", "./API.dll"] From 1a2e5cd3de0964d8bf38b046da7fca866fcfea3d Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 10:13:32 +0100 Subject: [PATCH 31/78] =?UTF-8?q?Ajout=20replace=20=C3=A0=20la=20place=20d?= =?UTF-8?q?e=20create?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index cbb0b9e..0d227d8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -78,7 +78,7 @@ steps: environment: IMAGENAME: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo CONTAINERNAME: sqluedo-api - COMMAND: create + COMMAND: replace OVERWRITE: true CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: from_secret: connection_string From 5a6561d9b3fc28e248a34b4477c0e85fa3c73083 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 13:50:50 +0100 Subject: [PATCH 32/78] Ajout du mirror --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 0d227d8..fcb8d30 100644 --- a/.drone.yml +++ b/.drone.yml @@ -67,6 +67,7 @@ steps: context: API_SQLuedo/ registry: hub.codefirst.iut.uca.fr repo: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo + mirror: https://proxy.iut.uca.fr:8443 username: from_secret: secret_registry_username password: From 373ddaeb493a5815cb0c22bed393ac4fd94e94e6 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 13:52:57 +0100 Subject: [PATCH 33/78] Ajout de create --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index fcb8d30..1403e89 100644 --- a/.drone.yml +++ b/.drone.yml @@ -79,7 +79,7 @@ steps: environment: IMAGENAME: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo CONTAINERNAME: sqluedo-api - COMMAND: replace + COMMAND: create OVERWRITE: true CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: from_secret: connection_string From 4fa79eabb20a6085b9c38fc8ad139635389e4a94 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 14:04:37 +0100 Subject: [PATCH 34/78] Test de debug --- .drone.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 1403e89..7db0ba7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -77,11 +77,9 @@ steps: - name: deploy-api-from-image image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: - IMAGENAME: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo + IMAGENAME: hub.codefirst.iut.uca.fr/johnny.ratton/api_sqluedo:latest CONTAINERNAME: sqluedo-api COMMAND: create OVERWRITE: true - CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: - from_secret: connection_string ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu - depends_on: [api-image-build-and-push] \ No newline at end of file + depends_on: [ api-image-build-and-push ] \ No newline at end of file From aa8d36ab9b9485bddf50c131f1c25f186b2d78f5 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 14:08:47 +0100 Subject: [PATCH 35/78] Ajout variable env --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index 7db0ba7..f2e02b0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -82,4 +82,6 @@ steps: COMMAND: create OVERWRITE: true ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu + CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: + from_secret: connection_string depends_on: [ api-image-build-and-push ] \ No newline at end of file From 3f955b9ae9e1447eec20565fc3f62da4ae2d98e8 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 14:21:46 +0100 Subject: [PATCH 36/78] Debug pour le port de l'api --- API_SQLuedo/API/Properties/launchSettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Properties/launchSettings.json b/API_SQLuedo/API/Properties/launchSettings.json index 63ba7b8..7f7c4c4 100644 --- a/API_SQLuedo/API/Properties/launchSettings.json +++ b/API_SQLuedo/API/Properties/launchSettings.json @@ -24,7 +24,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:7259;http://localhost:5015", + "applicationUrl": "https://localhost:8081;http://localhost:8080", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } From af7ccc2eb4258583ac6d5ee8ad00a1aaed730a6a Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 14:22:36 +0100 Subject: [PATCH 37/78] Suppression de la variable d'envrionnement --- .drone.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index f2e02b0..7db0ba7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -82,6 +82,4 @@ steps: COMMAND: create OVERWRITE: true ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu - CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: - from_secret: connection_string depends_on: [ api-image-build-and-push ] \ No newline at end of file From 556d002f217610c833cb2737c2cf225c871346a5 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 14:25:08 +0100 Subject: [PATCH 38/78] Suppression profil http --- API_SQLuedo/API/Properties/launchSettings.json | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/API_SQLuedo/API/Properties/launchSettings.json b/API_SQLuedo/API/Properties/launchSettings.json index 7f7c4c4..5c608f1 100644 --- a/API_SQLuedo/API/Properties/launchSettings.json +++ b/API_SQLuedo/API/Properties/launchSettings.json @@ -9,16 +9,6 @@ } }, "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "http://localhost:5015", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, "https": { "commandName": "Project", "dotnetRunMessages": true, From 37547cc6da75d94f51779662fea5fe27cd3c3d08 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 14:26:03 +0100 Subject: [PATCH 39/78] =?UTF-8?q?Suppression=20=C3=A9coute=20port=208080?= =?UTF-8?q?=20http?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Properties/launchSettings.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Properties/launchSettings.json b/API_SQLuedo/API/Properties/launchSettings.json index 5c608f1..5d588ec 100644 --- a/API_SQLuedo/API/Properties/launchSettings.json +++ b/API_SQLuedo/API/Properties/launchSettings.json @@ -9,12 +9,22 @@ } }, "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5015", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, "https": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:8081;http://localhost:8080", + "applicationUrl": "https://localhost:8081", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } From 81a387bab3d37606450f47709fa7fc753c8d029b Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 14:29:58 +0100 Subject: [PATCH 40/78] Debug --- API_SQLuedo/API/Properties/launchSettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Properties/launchSettings.json b/API_SQLuedo/API/Properties/launchSettings.json index 5d588ec..63ba7b8 100644 --- a/API_SQLuedo/API/Properties/launchSettings.json +++ b/API_SQLuedo/API/Properties/launchSettings.json @@ -24,7 +24,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:8081", + "applicationUrl": "https://localhost:7259;http://localhost:5015", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } From 9897d78582c3f31b6dd15125a2e51b86233956ea Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 14:31:58 +0100 Subject: [PATCH 41/78] =?UTF-8?q?Ajout=20du=20port=205015=20comme=20port?= =?UTF-8?q?=20expos=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Dockerfile b/API_SQLuedo/API/Dockerfile index e2db675..f185034 100644 --- a/API_SQLuedo/API/Dockerfile +++ b/API_SQLuedo/API/Dockerfile @@ -1,7 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER app WORKDIR /app -EXPOSE 8080 +EXPOSE 5015 EXPOSE 8081 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build From 596fc3da4f4d17a3508e325ab264255acd579950 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 14:36:19 +0100 Subject: [PATCH 42/78] Ajout port 8080 --- API_SQLuedo/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Dockerfile b/API_SQLuedo/API/Dockerfile index f185034..e2db675 100644 --- a/API_SQLuedo/API/Dockerfile +++ b/API_SQLuedo/API/Dockerfile @@ -1,7 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER app WORKDIR /app -EXPOSE 5015 +EXPOSE 8080 EXPOSE 8081 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build From 44c858e749e1385fc20f3adb8377988c1728786c Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 14:54:13 +0100 Subject: [PATCH 43/78] Tentative d'ajout dans le appsettings --- API_SQLuedo/API/appsettings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/API_SQLuedo/API/appsettings.json b/API_SQLuedo/API/appsettings.json index 10f68b8..ea8ad4c 100644 --- a/API_SQLuedo/API/appsettings.json +++ b/API_SQLuedo/API/appsettings.json @@ -1,4 +1,5 @@ { + "https_port": 8081, "Logging": { "LogLevel": { "Default": "Information", From 6074be56d279b974ee101e4ba0def1a54c40ba12 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 15:03:38 +0100 Subject: [PATCH 44/78] Ajout swagger hors developpement --- API_SQLuedo/API/Program.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index e34c27e..f4e19f8 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -115,12 +115,9 @@ using (var scope = app.Services.CreateScope()) } } -// Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) -{ - app.UseSwagger(); - app.UseSwaggerUI(); -} + +app.UseSwagger(); +app.UseSwaggerUI(); app.UseHttpsRedirection(); From e889bedde1cc1d69e1220f8372b0a4392fc98a27 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 15:08:59 +0100 Subject: [PATCH 45/78] Ajout var env pour la connection string --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index 7db0ba7..34d6a48 100644 --- a/.drone.yml +++ b/.drone.yml @@ -81,5 +81,7 @@ steps: CONTAINERNAME: sqluedo-api COMMAND: create OVERWRITE: true + CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: + from_secret: connection_string ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu depends_on: [ api-image-build-and-push ] \ No newline at end of file From 15cd6fb57b52afa1c7014ded2d0b43000d8cc3e8 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 15:12:24 +0100 Subject: [PATCH 46/78] Debug avec une autre env --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 34d6a48..4922979 100644 --- a/.drone.yml +++ b/.drone.yml @@ -81,7 +81,7 @@ steps: CONTAINERNAME: sqluedo-api COMMAND: create OVERWRITE: true - CODEFIRST_CLIENTDRONE_ENV_CONNECTION_STRING: - from_secret: connection_string + CODEFIRST_CLIENTDRONE_ENV_POSTGRES_USER: + from_secret: db_username ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu depends_on: [ api-image-build-and-push ] \ No newline at end of file From 076deea67f613aca5d1d38171b604e1e226045a4 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 15:14:24 +0100 Subject: [PATCH 47/78] Ajout debug string --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 4922979..99a76e4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -81,7 +81,7 @@ steps: CONTAINERNAME: sqluedo-api COMMAND: create OVERWRITE: true - CODEFIRST_CLIENTDRONE_ENV_POSTGRES_USER: + CODEFIRST_CLIENTDRONE_ENV_CO_STRING: from_secret: db_username ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu depends_on: [ api-image-build-and-push ] \ No newline at end of file From 6f38993d986698fbc1b9520bdea34876b5b799b6 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Thu, 28 Mar 2024 15:17:12 +0100 Subject: [PATCH 48/78] Modification de la connection string --- API_SQLuedo/DbContextLib/UserDbContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API_SQLuedo/DbContextLib/UserDbContext.cs b/API_SQLuedo/DbContextLib/UserDbContext.cs index b220b88..3c8c307 100644 --- a/API_SQLuedo/DbContextLib/UserDbContext.cs +++ b/API_SQLuedo/DbContextLib/UserDbContext.cs @@ -26,7 +26,7 @@ namespace DbContextLib base.OnConfiguring(optionsBuilder); if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseNpgsql(Environment.GetEnvironmentVariable("CONNECTION_STRING", EnvironmentVariableTarget.Process)); + optionsBuilder.UseNpgsql(Environment.GetEnvironmentVariable("CO_STRING", EnvironmentVariableTarget.Process)); //optionsBuilder.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=motdepasse"); } } From a5538bdc506112ad83bf11b380fe732f9a67f354 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Fri, 29 Mar 2024 12:42:42 +0100 Subject: [PATCH 49/78] =?UTF-8?q?Changement=20de=20port=20expos=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/API_SQLuedo/API/Dockerfile b/API_SQLuedo/API/Dockerfile index e2db675..a4d2864 100644 --- a/API_SQLuedo/API/Dockerfile +++ b/API_SQLuedo/API/Dockerfile @@ -1,8 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER app WORKDIR /app -EXPOSE 8080 -EXPOSE 8081 +EXPOSE 7259 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release From ef14986ef7a8eda9353d092ed180ce716924f1c3 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Fri, 29 Mar 2024 12:44:28 +0100 Subject: [PATCH 50/78] Ajout du port 8080 --- API_SQLuedo/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Dockerfile b/API_SQLuedo/API/Dockerfile index a4d2864..93fd7ac 100644 --- a/API_SQLuedo/API/Dockerfile +++ b/API_SQLuedo/API/Dockerfile @@ -1,7 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER app WORKDIR /app -EXPOSE 7259 +EXPOSE 8080 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release From b5e511efd038d4daf9970c70cca65f64bda65b0a Mon Sep 17 00:00:00 2001 From: Nestisse Date: Fri, 29 Mar 2024 13:04:15 +0100 Subject: [PATCH 51/78] Ajout de swagger vers la bonne route --- API_SQLuedo/API/Program.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index f4e19f8..f654150 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -117,7 +117,11 @@ using (var scope = app.Services.CreateScope()) app.UseSwagger(); -app.UseSwaggerUI(); +app.UseSwaggerUI(options => +{ + options.SwaggerEndpoint("./swagger/v1/swagger.json", "v1"); + options.RoutePrefix = "containers/johnnyratton-sqluedo-api"; +}); app.UseHttpsRedirection(); From dd5d0e2231d7314ff9bff114004965280fa390b5 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Fri, 29 Mar 2024 13:07:16 +0100 Subject: [PATCH 52/78] Suppression des options de swaggerui --- API_SQLuedo/API/Program.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index f654150..f4e19f8 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -117,11 +117,7 @@ using (var scope = app.Services.CreateScope()) app.UseSwagger(); -app.UseSwaggerUI(options => -{ - options.SwaggerEndpoint("./swagger/v1/swagger.json", "v1"); - options.RoutePrefix = "containers/johnnyratton-sqluedo-api"; -}); +app.UseSwaggerUI(); app.UseHttpsRedirection(); From 488ab60b9cde8976da4b68ccce82bc429731d97b Mon Sep 17 00:00:00 2001 From: Nestisse Date: Fri, 29 Mar 2024 13:08:40 +0100 Subject: [PATCH 53/78] Tentative d'ajout de route pour les inquiries --- API_SQLuedo/API/Controllers/InquiriesController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Controllers/InquiriesController.cs b/API_SQLuedo/API/Controllers/InquiriesController.cs index 0b412bc..fbd389b 100644 --- a/API_SQLuedo/API/Controllers/InquiriesController.cs +++ b/API_SQLuedo/API/Controllers/InquiriesController.cs @@ -7,7 +7,7 @@ using Asp.Versioning; namespace API.Controllers { - [Route("api/v{version:apiVersion}/[controller]")] + [Route("containers/johnnyratton-sqluedo-api/api/v{version:apiVersion}/[controller]")] [Authorize] [ApiVersion("1.0")] [ApiController] From ce8ab1cf368048c7cc010bf18a20303ab04e9d2e Mon Sep 17 00:00:00 2001 From: Nestisse Date: Fri, 29 Mar 2024 13:51:32 +0100 Subject: [PATCH 54/78] Ajout de settings pour swagger --- API_SQLuedo/API/Program.cs | 11 +++++++++-- API_SQLuedo/API/Properties/launchSettings.json | 6 +++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index f4e19f8..0c518d1 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -116,8 +116,15 @@ using (var scope = app.Services.CreateScope()) } -app.UseSwagger(); -app.UseSwaggerUI(); +app.UseSwagger(options => +{ + options.RouteTemplate = "containers/johnnyratton-sqluedo-api/{documentName}/swagger.json"; +}); +app.UseSwaggerUI(option => +{ + option.SwaggerEndpoint("/containers/johnnyratton-sqluedo-api/swagger/v1/swagger.json", "Demo API v1"); + option.RoutePrefix = "containers/johnnyratton-sqluedo-api"; +}); app.UseHttpsRedirection(); diff --git a/API_SQLuedo/API/Properties/launchSettings.json b/API_SQLuedo/API/Properties/launchSettings.json index 63ba7b8..02e776b 100644 --- a/API_SQLuedo/API/Properties/launchSettings.json +++ b/API_SQLuedo/API/Properties/launchSettings.json @@ -13,7 +13,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "launchUrl": "swagger", + "launchUrl": "containers/johnnyratton-sqluedo-api", "applicationUrl": "http://localhost:5015", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -23,7 +23,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "launchUrl": "swagger", + "launchUrl": "containers/johnnyratton-sqluedo-api", "applicationUrl": "https://localhost:7259;http://localhost:5015", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" @@ -32,7 +32,7 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "swagger", + "launchUrl": "containers/johnnyratton-sqluedo-api", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } From d980c972a476bf3306c277fd1e39ea6c6e62756a Mon Sep 17 00:00:00 2001 From: Nestisse Date: Fri, 29 Mar 2024 14:13:54 +0100 Subject: [PATCH 55/78] Debug --- API_SQLuedo/API/Dockerfile | 2 +- API_SQLuedo/API/Properties/launchSettings.json | 4 ++-- API_SQLuedo/API/appsettings.json | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/API_SQLuedo/API/Dockerfile b/API_SQLuedo/API/Dockerfile index 93fd7ac..b6db93c 100644 --- a/API_SQLuedo/API/Dockerfile +++ b/API_SQLuedo/API/Dockerfile @@ -1,7 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER app WORKDIR /app -EXPOSE 8080 +EXPOSE 8081 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release diff --git a/API_SQLuedo/API/Properties/launchSettings.json b/API_SQLuedo/API/Properties/launchSettings.json index 02e776b..06835e8 100644 --- a/API_SQLuedo/API/Properties/launchSettings.json +++ b/API_SQLuedo/API/Properties/launchSettings.json @@ -14,7 +14,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "containers/johnnyratton-sqluedo-api", - "applicationUrl": "http://localhost:5015", + "applicationUrl": "http://localhost:8081", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -24,7 +24,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "containers/johnnyratton-sqluedo-api", - "applicationUrl": "https://localhost:7259;http://localhost:5015", + "applicationUrl": "https://localhost:8081;http://localhost:5015", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/API_SQLuedo/API/appsettings.json b/API_SQLuedo/API/appsettings.json index ea8ad4c..464bd6f 100644 --- a/API_SQLuedo/API/appsettings.json +++ b/API_SQLuedo/API/appsettings.json @@ -1,5 +1,14 @@ { - "https_port": 8081, + "Kestrel": { + "EndPoints": { + "Http": { + "Url": "http://localhost:8081" + }, + "Https": { + "Url": "https://localhost:8081" + } + } + }, "Logging": { "LogLevel": { "Default": "Information", From ae50e581b1ce32eb5af657a80dbae0de884f9b31 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Fri, 29 Mar 2024 14:17:00 +0100 Subject: [PATCH 56/78] Suppression du profil https --- API_SQLuedo/API/appsettings.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/API_SQLuedo/API/appsettings.json b/API_SQLuedo/API/appsettings.json index 464bd6f..e15b2d6 100644 --- a/API_SQLuedo/API/appsettings.json +++ b/API_SQLuedo/API/appsettings.json @@ -3,9 +3,6 @@ "EndPoints": { "Http": { "Url": "http://localhost:8081" - }, - "Https": { - "Url": "https://localhost:8081" } } }, From 92ea8b4686d362bf9198fb408b27d99a35f318ae Mon Sep 17 00:00:00 2001 From: Nestisse Date: Fri, 29 Mar 2024 14:22:43 +0100 Subject: [PATCH 57/78] Suppression des endpoints via kernel --- API_SQLuedo/API/appsettings.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/API_SQLuedo/API/appsettings.json b/API_SQLuedo/API/appsettings.json index e15b2d6..10f68b8 100644 --- a/API_SQLuedo/API/appsettings.json +++ b/API_SQLuedo/API/appsettings.json @@ -1,11 +1,4 @@ { - "Kestrel": { - "EndPoints": { - "Http": { - "Url": "http://localhost:8081" - } - } - }, "Logging": { "LogLevel": { "Default": "Information", From 5bcfae1b17f6271a8e9113721ff15c9c1755bfce Mon Sep 17 00:00:00 2001 From: Clement CHIEU Date: Tue, 2 Apr 2024 14:01:27 +0200 Subject: [PATCH 58/78] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 343e215..1d90952 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ Voilà, vous pouvez maintenant utilisez librement l'API ! --- -### Versionnement +### Versionnement Notre API est versionnée ce qui signifie qu'à chaque requête, la version souhaitée de l'API doit être fournie. Pour l'instant, il n'y a qu'une __version 1.0__. From 06640b65307768573f8bf1ead0d6309b3e655c1d Mon Sep 17 00:00:00 2001 From: Clement CHIEU Date: Tue, 2 Apr 2024 15:11:12 +0200 Subject: [PATCH 59/78] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'API=5FSQLued?= =?UTF-8?q?o/API/Properties/launchSettings.json'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Properties/launchSettings.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/API_SQLuedo/API/Properties/launchSettings.json b/API_SQLuedo/API/Properties/launchSettings.json index 06835e8..963a27b 100644 --- a/API_SQLuedo/API/Properties/launchSettings.json +++ b/API_SQLuedo/API/Properties/launchSettings.json @@ -13,8 +13,8 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "launchUrl": "containers/johnnyratton-sqluedo-api", - "applicationUrl": "http://localhost:8081", + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5015", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -23,7 +23,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "launchUrl": "containers/johnnyratton-sqluedo-api", + "launchUrl": "swagger", "applicationUrl": "https://localhost:8081;http://localhost:5015", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" From 951ba2c941c8152aaab0b045a9a30319a8fb0ac4 Mon Sep 17 00:00:00 2001 From: Clement CHIEU Date: Tue, 2 Apr 2024 15:21:23 +0200 Subject: [PATCH 60/78] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'API=5FSQLued?= =?UTF-8?q?o/API/Program.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Program.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index 0c518d1..f4e19f8 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -116,15 +116,8 @@ using (var scope = app.Services.CreateScope()) } -app.UseSwagger(options => -{ - options.RouteTemplate = "containers/johnnyratton-sqluedo-api/{documentName}/swagger.json"; -}); -app.UseSwaggerUI(option => -{ - option.SwaggerEndpoint("/containers/johnnyratton-sqluedo-api/swagger/v1/swagger.json", "Demo API v1"); - option.RoutePrefix = "containers/johnnyratton-sqluedo-api"; -}); +app.UseSwagger(); +app.UseSwaggerUI(); app.UseHttpsRedirection(); From 590fa7d62904c1009106d398e5ab7f252504446e Mon Sep 17 00:00:00 2001 From: Clement CHIEU Date: Tue, 2 Apr 2024 15:25:44 +0200 Subject: [PATCH 61/78] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'API=5FSQLued?= =?UTF-8?q?o/API/Dockerfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Dockerfile b/API_SQLuedo/API/Dockerfile index b6db93c..93fd7ac 100644 --- a/API_SQLuedo/API/Dockerfile +++ b/API_SQLuedo/API/Dockerfile @@ -1,7 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER app WORKDIR /app -EXPOSE 8081 +EXPOSE 8080 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release From 9b30ed1234a2257cfe5878dab7a02af3dabc1704 Mon Sep 17 00:00:00 2001 From: Clement CHIEU Date: Tue, 2 Apr 2024 17:43:42 +0200 Subject: [PATCH 62/78] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'API=5FSQLued?= =?UTF-8?q?o/API/Dockerfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Dockerfile b/API_SQLuedo/API/Dockerfile index 93fd7ac..b3e7b27 100644 --- a/API_SQLuedo/API/Dockerfile +++ b/API_SQLuedo/API/Dockerfile @@ -1,7 +1,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER app WORKDIR /app -EXPOSE 8080 +EXPOSE 80 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release @@ -26,4 +26,6 @@ RUN dotnet publish "./API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:Use FROM base AS final WORKDIR /app COPY --from=publish /app/publish . +ENV ASPNETCORE_HTTP_PORTS=80 +ENV DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE=false ENTRYPOINT ["dotnet", "API.dll"] \ No newline at end of file From 509b0d75650b9bf099976d564f0199e932b33734 Mon Sep 17 00:00:00 2001 From: clchieu Date: Tue, 2 Apr 2024 18:07:15 +0200 Subject: [PATCH 63/78] =?UTF-8?q?V=C3=A9rification=20production?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Program.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index f4e19f8..a12b0d1 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -37,7 +37,14 @@ builder.Services.AddScoped, SuccessDataServiceApi>() builder.Services.AddScoped, LessonDataService>(); builder.Services.AddScoped, LessonDataServiceApi>(); -builder.Services.AddDbContext(); +builder.Services.AddDbContext(options => +{ + if (builder.Environment.IsProduction()) + { + throw new Exception("I am in production mode"); + } + throw new Exception("I am in development mode"); +}); builder.Services.AddDbContext(options => options.UseInMemoryDatabase("appDb")); builder.Services.AddIdentityApiEndpoints().AddEntityFrameworkStores(); From 0e1f873c9f32b4326c303a1c4ac9ccc386cee254 Mon Sep 17 00:00:00 2001 From: clchieu Date: Tue, 2 Apr 2024 18:09:05 +0200 Subject: [PATCH 64/78] =?UTF-8?q?V=C3=A9rification=20production?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Program.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index a12b0d1..b4a4679 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -41,9 +41,12 @@ builder.Services.AddDbContext(options => { if (builder.Environment.IsProduction()) { - throw new Exception("I am in production mode"); + Console.WriteLine("I am in production mode"); + } + else + { + Console.WriteLine("I am in development mode"); } - throw new Exception("I am in development mode"); }); builder.Services.AddDbContext(options => options.UseInMemoryDatabase("appDb")); builder.Services.AddIdentityApiEndpoints().AddEntityFrameworkStores(); From 1ec09bdedfa75a1be151fe80ec20823e175b9cbd Mon Sep 17 00:00:00 2001 From: clchieu Date: Tue, 2 Apr 2024 18:14:47 +0200 Subject: [PATCH 65/78] =?UTF-8?q?Modification=20du=20context=20utilis?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Program.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index b4a4679..3977b7a 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -48,8 +48,7 @@ builder.Services.AddDbContext(options => Console.WriteLine("I am in development mode"); } }); -builder.Services.AddDbContext(options => options.UseInMemoryDatabase("appDb")); -builder.Services.AddIdentityApiEndpoints().AddEntityFrameworkStores(); +builder.Services.AddIdentityApiEndpoints().AddEntityFrameworkStores(); builder.Services.AddAuthorization(); builder.Services.AddApiVersioning(o => From 570f89b4e352ee22a5ce32e3591084f1ac6cfaf7 Mon Sep 17 00:00:00 2001 From: clchieu Date: Tue, 2 Apr 2024 18:18:02 +0200 Subject: [PATCH 66/78] =?UTF-8?q?Ajout=20de=20l'utilisation=20de=20la=20va?= =?UTF-8?q?riable=20d'environnement=20au=20moment=20de=20la=20cr=C3=A9atio?= =?UTF-8?q?n=20de=20l'api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index 3977b7a..45dbd20 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -42,6 +42,7 @@ builder.Services.AddDbContext(options => if (builder.Environment.IsProduction()) { Console.WriteLine("I am in production mode"); + options.UseNpgsql(Environment.GetEnvironmentVariable("CO_STRING", EnvironmentVariableTarget.Process)); } else { From c0763ae9a9841d6666b8b3c6f583a5bb4d7cd5cf Mon Sep 17 00:00:00 2001 From: Clement CHIEU Date: Tue, 2 Apr 2024 18:28:26 +0200 Subject: [PATCH 67/78] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 99a76e4..cee2737 100644 --- a/.drone.yml +++ b/.drone.yml @@ -81,7 +81,13 @@ steps: CONTAINERNAME: sqluedo-api COMMAND: create OVERWRITE: true - CODEFIRST_CLIENTDRONE_ENV_CO_STRING: + CODEFIRST_CLIENTDRONE_ENV_DB_HOST: + from_secret: db_host + CODEFIRST_CLIENTDRONE_ENV_DB_USER: from_secret: db_username + CODEFIRST_CLIENTDRONE_ENV_DB_PASSWORD: + from_secret: db_password + CODEFIRST_CLIENTDRONE_ENV_DB_DATABASE: + from_secret: db_database ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu depends_on: [ api-image-build-and-push ] \ No newline at end of file From c95dc22881f9fc977b312bc6a3d80dc7e52dec44 Mon Sep 17 00:00:00 2001 From: clchieu Date: Tue, 2 Apr 2024 18:32:44 +0200 Subject: [PATCH 68/78] Ajout des bonnes variables d'environnement --- API_SQLuedo/API/Program.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index 45dbd20..35c1527 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -42,7 +42,17 @@ builder.Services.AddDbContext(options => if (builder.Environment.IsProduction()) { Console.WriteLine("I am in production mode"); - options.UseNpgsql(Environment.GetEnvironmentVariable("CO_STRING", EnvironmentVariableTarget.Process)); + var address = Environment.GetEnvironmentVariable("DB_HOST", EnvironmentVariableTarget.Process) + ?? throw new ArgumentException("Missing DB_HOST environment variable"); + var database = Environment.GetEnvironmentVariable("DB_DATABASE", EnvironmentVariableTarget.Process) + ?? throw new ArgumentException("Missing DB_DATABASE environment variable"); + var user = Environment.GetEnvironmentVariable("DB_USER", EnvironmentVariableTarget.Process) + ?? throw new ArgumentException("Missing DB_USER environment variable"); + var password = Environment.GetEnvironmentVariable("DB_PASSWORD", EnvironmentVariableTarget.Process) + ?? throw new ArgumentException("Missing DB_PASSWORD environment variable"); + + var coString = $"Host={address};Database={database};Username={user};Password={password}"; + options.UseNpgsql(coString); } else { From ad41f1dd4143790d0f24b968aef30af3558a6696 Mon Sep 17 00:00:00 2001 From: clchieu Date: Tue, 2 Apr 2024 18:49:25 +0200 Subject: [PATCH 69/78] =?UTF-8?q?Ajout=20de=20la=20connection=20string=20p?= =?UTF-8?q?our=20le=20d=C3=A9veloppement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index 35c1527..e21ac69 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -57,6 +57,7 @@ builder.Services.AddDbContext(options => else { Console.WriteLine("I am in development mode"); + options.UseNpgsql("Host=localhost;Database=SQLuedo;Username=admin;Password=motdepasse"); } }); builder.Services.AddIdentityApiEndpoints().AddEntityFrameworkStores(); From edc2e1055c9d0d2ddd417f31b6bba26cab5e388e Mon Sep 17 00:00:00 2001 From: Clement CHIEU Date: Tue, 2 Apr 2024 19:31:05 +0200 Subject: [PATCH 70/78] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.gitignore'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 80077b2..a6593e5 100644 --- a/.gitignore +++ b/.gitignore @@ -492,8 +492,7 @@ fabric.properties .idea/caches/build_file_checksums.ser -# Migrations et fichiers db -**/Migrations/** +# Fichier db *.db /**/.idea/ From 0f0615c5a24c9e67ba7326880a94f3cf6bf598b6 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Tue, 2 Apr 2024 19:50:28 +0200 Subject: [PATCH 71/78] Ajout migrations --- .../20240402175009_prod.Designer.cs | 595 ++++++++++++++++++ .../Migrations/20240402175009_prod.cs | 452 +++++++++++++ .../Migrations/UserDbContextModelSnapshot.cs | 592 +++++++++++++++++ 3 files changed, 1639 insertions(+) create mode 100644 API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.Designer.cs create mode 100644 API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.cs create mode 100644 API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs diff --git a/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.Designer.cs b/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.Designer.cs new file mode 100644 index 0000000..692d7b4 --- /dev/null +++ b/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.Designer.cs @@ -0,0 +1,595 @@ +// +using System; +using DbContextLib; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DbContextLib.Migrations +{ + [DbContext(typeof(UserDbContext))] + [Migration("20240402175009_prod")] + partial class prod + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.HasSequence("ContentLessonEntitySequence"); + + modelBuilder.Entity("Entities.BlackListEntity", b => + { + b.Property("Email") + .HasColumnType("text"); + + b.Property("ExpirationDate") + .HasColumnType("date"); + + b.HasKey("Email"); + + b.ToTable("BlackList"); + }); + + modelBuilder.Entity("Entities.ContentLessonEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValueSql("nextval('\"ContentLessonEntitySequence\"')"); + + NpgsqlPropertyBuilderExtensions.UseSequence(b.Property("Id")); + + b.Property("ContentContent") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContentTitle") + .IsRequired() + .HasColumnType("text"); + + b.Property("LessonId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("LessonId"); + + b.ToTable((string)null); + + b.UseTpcMappingStrategy(); + }); + + modelBuilder.Entity("Entities.InquiryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsUser") + .HasColumnType("boolean"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Inquiries"); + }); + + modelBuilder.Entity("Entities.InquiryTableEntity", b => + { + b.Property("OwnerId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + b.Property("ConnectionInfo") + .IsRequired() + .HasColumnType("text"); + + b.Property("DatabaseName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("OwnerId"); + + b.ToTable("InquiryTable"); + }); + + modelBuilder.Entity("Entities.LessonEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LastEdit") + .HasColumnType("date"); + + b.Property("LastPublisher") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Lesson"); + }); + + modelBuilder.Entity("Entities.NotepadEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("InquiryId") + .HasColumnType("integer"); + + b.Property("Notes") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InquiryId"); + + b.HasIndex("UserId"); + + b.ToTable("Notepad"); + }); + + modelBuilder.Entity("Entities.SolutionEntity", b => + { + b.Property("OwnerId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + b.Property("Explaination") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurderPlace") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurderWeapon") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurdererFirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurdererLastName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("OwnerId"); + + b.ToTable("Solution"); + }); + + modelBuilder.Entity("Entities.SuccessEntity", b => + { + b.Property("InquiryId") + .HasColumnType("integer"); + + b.Property("IsFinished") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("InquiryId"); + + b.HasIndex("UserId"); + + b.ToTable("Success"); + }); + + modelBuilder.Entity("Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsAdmin") + .HasColumnType("boolean"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Entities.ParagraphEntity", b => + { + b.HasBaseType("Entities.ContentLessonEntity"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("Info") + .IsRequired() + .HasColumnType("text"); + + b.Property("Query") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.ToTable("Paragraph"); + }); + + modelBuilder.Entity("Entities.ContentLessonEntity", b => + { + b.HasOne("Entities.LessonEntity", "Lesson") + .WithMany("Content") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("Entities.InquiryTableEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Entities.NotepadEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Inquiry") + .WithMany() + .HasForeignKey("InquiryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.UserEntity", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Inquiry"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Entities.SolutionEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Entities.SuccessEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Inquiry") + .WithMany() + .HasForeignKey("InquiryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.UserEntity", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Inquiry"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entities.LessonEntity", b => + { + b.Navigation("Content"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.cs b/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.cs new file mode 100644 index 0000000..7543a7e --- /dev/null +++ b/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.cs @@ -0,0 +1,452 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DbContextLib.Migrations +{ + /// + public partial class prod : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateSequence( + name: "ContentLessonEntitySequence"); + + migrationBuilder.CreateTable( + name: "AspNetRoles", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetUsers", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "boolean", nullable: false), + PasswordHash = table.Column(type: "text", nullable: true), + SecurityStamp = table.Column(type: "text", nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true), + PhoneNumber = table.Column(type: "text", nullable: true), + PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), + TwoFactorEnabled = table.Column(type: "boolean", nullable: false), + LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), + LockoutEnabled = table.Column(type: "boolean", nullable: false), + AccessFailedCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "BlackList", + columns: table => new + { + Email = table.Column(type: "text", nullable: false), + ExpirationDate = table.Column(type: "date", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BlackList", x => x.Email); + }); + + migrationBuilder.CreateTable( + name: "Inquiries", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Title = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + IsUser = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Inquiries", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Lesson", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Title = table.Column(type: "text", nullable: false), + LastPublisher = table.Column(type: "text", nullable: false), + LastEdit = table.Column(type: "date", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Lesson", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "User", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Username = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false), + Email = table.Column(type: "text", nullable: false), + IsAdmin = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_User", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetRoleClaims", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "text", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserClaims", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "text", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetUserClaims_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserLogins", + columns: table => new + { + LoginProvider = table.Column(type: "text", nullable: false), + ProviderKey = table.Column(type: "text", nullable: false), + ProviderDisplayName = table.Column(type: "text", nullable: true), + UserId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_AspNetUserLogins_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserRoles", + columns: table => new + { + UserId = table.Column(type: "text", nullable: false), + RoleId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserTokens", + columns: table => new + { + UserId = table.Column(type: "text", nullable: false), + LoginProvider = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AspNetUserTokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "InquiryTable", + columns: table => new + { + OwnerId = table.Column(type: "integer", nullable: false), + DatabaseName = table.Column(type: "text", nullable: false), + ConnectionInfo = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InquiryTable", x => x.OwnerId); + table.ForeignKey( + name: "FK_InquiryTable_Inquiries_OwnerId", + column: x => x.OwnerId, + principalTable: "Inquiries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Solution", + columns: table => new + { + OwnerId = table.Column(type: "integer", nullable: false), + MurdererFirstName = table.Column(type: "text", nullable: false), + MurdererLastName = table.Column(type: "text", nullable: false), + MurderPlace = table.Column(type: "text", nullable: false), + MurderWeapon = table.Column(type: "text", nullable: false), + Explaination = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Solution", x => x.OwnerId); + table.ForeignKey( + name: "FK_Solution_Inquiries_OwnerId", + column: x => x.OwnerId, + principalTable: "Inquiries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Paragraph", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false, defaultValueSql: "nextval('\"ContentLessonEntitySequence\"')"), + ContentContent = table.Column(type: "text", nullable: false), + ContentTitle = table.Column(type: "text", nullable: false), + LessonId = table.Column(type: "integer", nullable: false), + Title = table.Column(type: "text", nullable: false), + Content = table.Column(type: "text", nullable: false), + Info = table.Column(type: "text", nullable: false), + Query = table.Column(type: "text", nullable: false), + Comment = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Paragraph", x => x.Id); + table.ForeignKey( + name: "FK_Paragraph_Lesson_LessonId", + column: x => x.LessonId, + principalTable: "Lesson", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Notepad", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "integer", nullable: false), + InquiryId = table.Column(type: "integer", nullable: false), + Notes = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Notepad", x => x.Id); + table.ForeignKey( + name: "FK_Notepad_Inquiries_InquiryId", + column: x => x.InquiryId, + principalTable: "Inquiries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Notepad_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Success", + columns: table => new + { + InquiryId = table.Column(type: "integer", nullable: false), + UserId = table.Column(type: "integer", nullable: false), + IsFinished = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Success", x => x.InquiryId); + table.ForeignKey( + name: "FK_Success_Inquiries_InquiryId", + column: x => x.InquiryId, + principalTable: "Inquiries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Success_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AspNetRoleClaims_RoleId", + table: "AspNetRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + table: "AspNetRoles", + column: "NormalizedName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserClaims_UserId", + table: "AspNetUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserLogins_UserId", + table: "AspNetUserLogins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserRoles_RoleId", + table: "AspNetUserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + table: "AspNetUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + table: "AspNetUsers", + column: "NormalizedUserName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Notepad_InquiryId", + table: "Notepad", + column: "InquiryId"); + + migrationBuilder.CreateIndex( + name: "IX_Notepad_UserId", + table: "Notepad", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Paragraph_LessonId", + table: "Paragraph", + column: "LessonId"); + + migrationBuilder.CreateIndex( + name: "IX_Success_UserId", + table: "Success", + column: "UserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AspNetRoleClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserLogins"); + + migrationBuilder.DropTable( + name: "AspNetUserRoles"); + + migrationBuilder.DropTable( + name: "AspNetUserTokens"); + + migrationBuilder.DropTable( + name: "BlackList"); + + migrationBuilder.DropTable( + name: "InquiryTable"); + + migrationBuilder.DropTable( + name: "Notepad"); + + migrationBuilder.DropTable( + name: "Paragraph"); + + migrationBuilder.DropTable( + name: "Solution"); + + migrationBuilder.DropTable( + name: "Success"); + + migrationBuilder.DropTable( + name: "AspNetRoles"); + + migrationBuilder.DropTable( + name: "AspNetUsers"); + + migrationBuilder.DropTable( + name: "Lesson"); + + migrationBuilder.DropTable( + name: "Inquiries"); + + migrationBuilder.DropTable( + name: "User"); + + migrationBuilder.DropSequence( + name: "ContentLessonEntitySequence"); + } + } +} diff --git a/API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs b/API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs new file mode 100644 index 0000000..50a98ac --- /dev/null +++ b/API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs @@ -0,0 +1,592 @@ +// +using System; +using DbContextLib; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DbContextLib.Migrations +{ + [DbContext(typeof(UserDbContext))] + partial class UserDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.HasSequence("ContentLessonEntitySequence"); + + modelBuilder.Entity("Entities.BlackListEntity", b => + { + b.Property("Email") + .HasColumnType("text"); + + b.Property("ExpirationDate") + .HasColumnType("date"); + + b.HasKey("Email"); + + b.ToTable("BlackList"); + }); + + modelBuilder.Entity("Entities.ContentLessonEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValueSql("nextval('\"ContentLessonEntitySequence\"')"); + + NpgsqlPropertyBuilderExtensions.UseSequence(b.Property("Id")); + + b.Property("ContentContent") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContentTitle") + .IsRequired() + .HasColumnType("text"); + + b.Property("LessonId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("LessonId"); + + b.ToTable((string)null); + + b.UseTpcMappingStrategy(); + }); + + modelBuilder.Entity("Entities.InquiryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsUser") + .HasColumnType("boolean"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Inquiries"); + }); + + modelBuilder.Entity("Entities.InquiryTableEntity", b => + { + b.Property("OwnerId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + b.Property("ConnectionInfo") + .IsRequired() + .HasColumnType("text"); + + b.Property("DatabaseName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("OwnerId"); + + b.ToTable("InquiryTable"); + }); + + modelBuilder.Entity("Entities.LessonEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LastEdit") + .HasColumnType("date"); + + b.Property("LastPublisher") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Lesson"); + }); + + modelBuilder.Entity("Entities.NotepadEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("InquiryId") + .HasColumnType("integer"); + + b.Property("Notes") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InquiryId"); + + b.HasIndex("UserId"); + + b.ToTable("Notepad"); + }); + + modelBuilder.Entity("Entities.SolutionEntity", b => + { + b.Property("OwnerId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + b.Property("Explaination") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurderPlace") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurderWeapon") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurdererFirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurdererLastName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("OwnerId"); + + b.ToTable("Solution"); + }); + + modelBuilder.Entity("Entities.SuccessEntity", b => + { + b.Property("InquiryId") + .HasColumnType("integer"); + + b.Property("IsFinished") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("InquiryId"); + + b.HasIndex("UserId"); + + b.ToTable("Success"); + }); + + modelBuilder.Entity("Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsAdmin") + .HasColumnType("boolean"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Entities.ParagraphEntity", b => + { + b.HasBaseType("Entities.ContentLessonEntity"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("Info") + .IsRequired() + .HasColumnType("text"); + + b.Property("Query") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.ToTable("Paragraph"); + }); + + modelBuilder.Entity("Entities.ContentLessonEntity", b => + { + b.HasOne("Entities.LessonEntity", "Lesson") + .WithMany("Content") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("Entities.InquiryTableEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Entities.NotepadEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Inquiry") + .WithMany() + .HasForeignKey("InquiryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.UserEntity", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Inquiry"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Entities.SolutionEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Entities.SuccessEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Inquiry") + .WithMany() + .HasForeignKey("InquiryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.UserEntity", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Inquiry"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entities.LessonEntity", b => + { + b.Navigation("Content"); + }); +#pragma warning restore 612, 618 + } + } +} From a4f75d948a568e81bacc3506f8674ae005679fbe Mon Sep 17 00:00:00 2001 From: Nestisse Date: Tue, 2 Apr 2024 19:52:52 +0200 Subject: [PATCH 72/78] =?UTF-8?q?Ajout=20pour=20migrer=20vers=20la=20base?= =?UTF-8?q?=20de=20donn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API_SQLuedo/API/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/API_SQLuedo/API/Program.cs b/API_SQLuedo/API/Program.cs index e21ac69..c85113e 100644 --- a/API_SQLuedo/API/Program.cs +++ b/API_SQLuedo/API/Program.cs @@ -111,6 +111,10 @@ var app = builder.Build(); using (var scope = app.Services.CreateScope()) { var services = scope.ServiceProvider; + // Création base de données via les migrations + await using var dbContext = services.GetRequiredService(); + await dbContext.Database.MigrateAsync(); + var userManager = services.GetRequiredService>(); try From 037d3c5d7d463534ed6abad347499058b388de75 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Tue, 2 Apr 2024 20:46:09 +0200 Subject: [PATCH 73/78] Suppression de la route de test du controller --- API_SQLuedo/API/Controllers/InquiriesController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/API_SQLuedo/API/Controllers/InquiriesController.cs b/API_SQLuedo/API/Controllers/InquiriesController.cs index fbd389b..e1801d0 100644 --- a/API_SQLuedo/API/Controllers/InquiriesController.cs +++ b/API_SQLuedo/API/Controllers/InquiriesController.cs @@ -7,7 +7,6 @@ using Asp.Versioning; namespace API.Controllers { - [Route("containers/johnnyratton-sqluedo-api/api/v{version:apiVersion}/[controller]")] [Authorize] [ApiVersion("1.0")] [ApiController] From 3a6693646c5e5d2fc20a911ef42cd7eb820f7254 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Tue, 2 Apr 2024 20:50:42 +0200 Subject: [PATCH 74/78] Ajout des bonnes routes des controller --- .../API/Controllers/BlackListController.cs | 25 +- .../API/Controllers/InquiriesController.cs | 212 +++++----- .../API/Controllers/LessonsController.cs | 236 ++++++----- .../API/Controllers/ParagraphsController.cs | 219 +++++----- .../API/Controllers/SuccessesController.cs | 389 +++++++++--------- API_SQLuedo/API/Controllers/UserController.cs | 333 ++++++++------- 6 files changed, 708 insertions(+), 706 deletions(-) diff --git a/API_SQLuedo/API/Controllers/BlackListController.cs b/API_SQLuedo/API/Controllers/BlackListController.cs index 7f2bc56..c9136e6 100644 --- a/API_SQLuedo/API/Controllers/BlackListController.cs +++ b/API_SQLuedo/API/Controllers/BlackListController.cs @@ -1,13 +1,18 @@ +using Asp.Versioning; using Dto; -using Entities; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Model.OrderCriteria; using Shared; -using Shared.Mapper; namespace API.Controllers; -public class BlackListController(ILogger logger, IBlackListService blackListService) : ControllerBase +[Route("api/v{version:apiVersion}/[controller]")] +[Authorize] +[ApiVersion("1.0")] +[ApiController] +public class BlackListController(ILogger logger, IBlackListService blackListService) + : ControllerBase { [HttpGet("user/ban/{page:int}/{number:int}")] [ProducesResponseType(typeof(IEnumerable), 200)] @@ -24,7 +29,7 @@ public class BlackListController(ILogger logger, IBlackListServ logger.LogInformation("[INFORMATION] {nb} Email(s) banni(s) trouvé(s)", users.Count); return Ok(users); } - + [HttpGet("user/ban/number")] [ProducesResponseType(typeof(UserDto), 200)] [ProducesResponseType(typeof(string), 204)] @@ -34,7 +39,7 @@ public class BlackListController(ILogger logger, IBlackListServ logger.LogInformation("[INFORMATION] {nb} Email(s) banni(s) trouvé(s)", nb); return Ok(nb); } - + [HttpPost("user/ban")] [ProducesResponseType(typeof(UserDto), 200)] [ProducesResponseType(typeof(string), 404)] @@ -44,12 +49,13 @@ public class BlackListController(ILogger logger, IBlackListServ if (res != null) { logger.LogInformation("[INFORMATION] Utilisateur banni avec l'email {email} a été trouvé.", email); - return Ok(res); + return Ok(res); } + logger.LogError("[ERREUR] Aucun utilisateur banni trouvé avec l'email {email}.", email); return NotFound("Utilisateur non trouvé !"); } - + [HttpDelete("user/ban/{username:alpha}")] [ProducesResponseType(typeof(UserDto), 200)] [ProducesResponseType(typeof(string), 404)] @@ -58,7 +64,8 @@ public class BlackListController(ILogger logger, IBlackListServ var success = blackListService.BanUser(username); if (success) { - logger.LogInformation("[INFORMATION] L'utilisateur avec le pseudo {username} a été banni pour 2 ans.", username); + logger.LogInformation("[INFORMATION] L'utilisateur avec le pseudo {username} a été banni pour 2 ans.", + username); return Ok(); } else @@ -67,7 +74,7 @@ public class BlackListController(ILogger logger, IBlackListServ return NotFound(); } } - + [HttpPost("user/unban")] [ProducesResponseType(typeof(UserDto), 200)] [ProducesResponseType(typeof(string), 404)] diff --git a/API_SQLuedo/API/Controllers/InquiriesController.cs b/API_SQLuedo/API/Controllers/InquiriesController.cs index e1801d0..2829b56 100644 --- a/API_SQLuedo/API/Controllers/InquiriesController.cs +++ b/API_SQLuedo/API/Controllers/InquiriesController.cs @@ -5,135 +5,135 @@ using Model.OrderCriteria; using Shared; using Asp.Versioning; -namespace API.Controllers +namespace API.Controllers; + +[Route("api/v{version:apiVersion}/[controller]")] +[Authorize] +[ApiVersion("1.0")] +[ApiController] +public class InquiriesController : Controller { - [Authorize] - [ApiVersion("1.0")] - [ApiController] - public class InquiriesController : Controller - { - private readonly IInquiryService _inquiryDataService; + private readonly IInquiryService _inquiryDataService; + + private readonly ILogger _logger; - private readonly ILogger _logger; + public InquiriesController(IInquiryService inquiryDataService, ILogger logger) + { + _inquiryDataService = inquiryDataService; + _logger = logger; + } - public InquiriesController(IInquiryService inquiryDataService, ILogger logger) + [HttpGet("inquiries/{page:int}/{number:int}/{orderCriteria}")] + [ProducesResponseType(typeof(InquiryDto), 200)] + [ProducesResponseType(typeof(string), 204)] + public IActionResult GetInquiries(int page, int number, InquiryOrderCriteria orderCriteria) + { + var nbInquiry = _inquiryDataService.GetInquiries(page, number, orderCriteria).Count(); + if (nbInquiry == 0) { - _inquiryDataService = inquiryDataService; - _logger = logger; + _logger.LogError("[ERREUR] Aucune enquête trouvée."); + return StatusCode(204); } - [HttpGet("inquiries/{page:int}/{number:int}/{orderCriteria}")] - [ProducesResponseType(typeof(InquiryDto), 200)] - [ProducesResponseType(typeof(string), 204)] - public IActionResult GetInquiries(int page, int number, InquiryOrderCriteria orderCriteria) - { - var nbInquiry = _inquiryDataService.GetInquiries(page, number, orderCriteria).Count(); - if (nbInquiry == 0) - { - _logger.LogError("[ERREUR] Aucune enquête trouvée."); - return StatusCode(204); - } + _logger.LogInformation("[INFORMATION] {nb} Enquête(s) trouvée(s)", nbInquiry); + return Ok(_inquiryDataService.GetInquiries(page, number, orderCriteria)); + } - _logger.LogInformation("[INFORMATION] {nb} Enquête(s) trouvée(s)", nbInquiry); - return Ok(_inquiryDataService.GetInquiries(page, number, orderCriteria)); + [HttpGet("inquiry/{id:int}")] + [ProducesResponseType(typeof(InquiryDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetInquiryById(int id) + { + try + { + _logger.LogInformation("[INFORMATION] L'enquête avec l'id {id} a été trouvé.", id); + return Ok(_inquiryDataService.GetInquiryById(id)); } - - [HttpGet("inquiry/{id:int}")] - [ProducesResponseType(typeof(InquiryDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetInquiryById(int id) + catch (ArgumentException) { - try - { - _logger.LogInformation("[INFORMATION] L'enquête avec l'id {id} a été trouvé.", id); - return Ok(_inquiryDataService.GetInquiryById(id)); - } - catch (ArgumentException) - { - _logger.LogError("[ERREUR] Aucune enquête trouvée avec l'id {id}.", id); - return NotFound(); - } + _logger.LogError("[ERREUR] Aucune enquête trouvée avec l'id {id}.", id); + return NotFound(); } + } - [HttpGet("inquiry/{title:alpha}")] - [ProducesResponseType(typeof(InquiryDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetInquiryByTitle(string title) + [HttpGet("inquiry/{title:alpha}")] + [ProducesResponseType(typeof(InquiryDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetInquiryByTitle(string title) + { + try { - try - { - _logger.LogInformation("[INFORMATION] L'enquête avec le titre {title} a été trouvé.", title); - return Ok(_inquiryDataService.GetInquiryByTitle(title)); - } - catch (ArgumentException) - { - _logger.LogError("[ERREUR] Aucune enquête trouvée avec le titre {title}.", title); - return NotFound(); - } + _logger.LogInformation("[INFORMATION] L'enquête avec le titre {title} a été trouvé.", title); + return Ok(_inquiryDataService.GetInquiryByTitle(title)); } - - [HttpDelete("inquiry/{id:int}")] - [ProducesResponseType(typeof(InquiryDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult DeleteInquiry(int id) + catch (ArgumentException) { - var success = _inquiryDataService.DeleteInquiry(id); - if (success) - { - _logger.LogInformation("[INFORMATION] L'enquête avec l'id {id} a été supprimé.", id); - return Ok(_inquiryDataService.DeleteInquiry(id)); - } - else - { - _logger.LogError("[ERREUR] Aucune enquête trouvée avec l'id {id}.", id); - return NotFound(); - } + _logger.LogError("[ERREUR] Aucune enquête trouvée avec le titre {title}.", title); + return NotFound(); } + } - [HttpPost] - [ProducesResponseType(typeof(InquiryDto), 201)] - [ProducesResponseType(typeof(string), 400)] - public IActionResult CreateInquiry([FromBody] InquiryDto dto) + [HttpDelete("inquiry/{id:int}")] + [ProducesResponseType(typeof(InquiryDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult DeleteInquiry(int id) + { + var success = _inquiryDataService.DeleteInquiry(id); + if (success) { - if (dto.Title == null || dto.Description == null) - { - return BadRequest(); - } - - _logger.LogInformation( - "[INFORMATION] Une enquête a été créé : title - {title}, description - {description}, isUser - {isUser}", - dto.Title, dto.Description, dto.IsUser); - return Created(nameof(GetInquiries), - _inquiryDataService.CreateInquiry(dto.Title, dto.Description, dto.IsUser)); + _logger.LogInformation("[INFORMATION] L'enquête avec l'id {id} a été supprimé.", id); + return Ok(_inquiryDataService.DeleteInquiry(id)); + } + else + { + _logger.LogError("[ERREUR] Aucune enquête trouvée avec l'id {id}.", id); + return NotFound(); } + } - [HttpPut("inquiry/{id:int}")] - [ProducesResponseType(typeof(InquiryDto), 200)] - [ProducesResponseType(typeof(string), 400)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult UpdateInquiry(int id, [FromBody] InquiryDto InquiryDto) + [HttpPost] + [ProducesResponseType(typeof(InquiryDto), 201)] + [ProducesResponseType(typeof(string), 400)] + public IActionResult CreateInquiry([FromBody] InquiryDto dto) + { + if (dto.Title == null || dto.Description == null) { - if (id != InquiryDto.Id) - { - _logger.LogError("[ERREUR] Problème ID - La mise à jour de l'enquête avec l'id {id} a échouée.", id); - return BadRequest(); - } + return BadRequest(); + } - if (!ModelState.IsValid) - { - _logger.LogError( - "[ERREUR] Problème controlleur - La mise à jour de l'enquête avec l'id {id} a échouée.", id); - return BadRequest(); - } + _logger.LogInformation( + "[INFORMATION] Une enquête a été créé : title - {title}, description - {description}, isUser - {isUser}", + dto.Title, dto.Description, dto.IsUser); + return Created(nameof(GetInquiries), + _inquiryDataService.CreateInquiry(dto.Title, dto.Description, dto.IsUser)); + } - if (InquiryDto != null) - { - _logger.LogInformation("[INFORMATION] La mise à jour de l'enquête avec l'id {id} a été effectuée", id); - return Ok(_inquiryDataService.UpdateInquiry(id, InquiryDto)); - } + [HttpPut("inquiry/{id:int}")] + [ProducesResponseType(typeof(InquiryDto), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult UpdateInquiry(int id, [FromBody] InquiryDto InquiryDto) + { + if (id != InquiryDto.Id) + { + _logger.LogError("[ERREUR] Problème ID - La mise à jour de l'enquête avec l'id {id} a échouée.", id); + return BadRequest(); + } - _logger.LogError("[ERREUR] Aucune enquête trouvée avec l'id {id}.", id); - return NotFound(); + if (!ModelState.IsValid) + { + _logger.LogError( + "[ERREUR] Problème controlleur - La mise à jour de l'enquête avec l'id {id} a échouée.", id); + return BadRequest(); } + + if (InquiryDto != null) + { + _logger.LogInformation("[INFORMATION] La mise à jour de l'enquête avec l'id {id} a été effectuée", id); + return Ok(_inquiryDataService.UpdateInquiry(id, InquiryDto)); + } + + _logger.LogError("[ERREUR] Aucune enquête trouvée avec l'id {id}.", id); + return NotFound(); } } \ No newline at end of file diff --git a/API_SQLuedo/API/Controllers/LessonsController.cs b/API_SQLuedo/API/Controllers/LessonsController.cs index c02cc6b..8d28149 100644 --- a/API_SQLuedo/API/Controllers/LessonsController.cs +++ b/API_SQLuedo/API/Controllers/LessonsController.cs @@ -1,155 +1,153 @@ -using System.Net; -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Dto; using Model.OrderCriteria; using Shared; using Asp.Versioning; -namespace API.Controllers +namespace API.Controllers; + +[Route("api/v{version:apiVersion}/[controller]")] +[Authorize] +[ApiVersion("1.0")] +[ApiController] +public class LessonsController : Controller { - [Route("api/v{version:apiVersion}/[controller]")] - [Authorize] - [ApiVersion("1.0")] - [ApiController] - public class LessonsController : Controller - { - private readonly ILessonService _lessonDataService; + private readonly ILessonService _lessonDataService; - private readonly ILogger _logger; + private readonly ILogger _logger; + + public LessonsController(ILessonService lessonDataService, ILogger logger) + { + _lessonDataService = lessonDataService; + _logger = logger; + } - public LessonsController(ILessonService lessonDataService, ILogger logger) + [HttpGet("lessons/{page:int}/{number:int}/{orderCriteria}")] + [ProducesResponseType(typeof(LessonDto), 200)] + [ProducesResponseType(typeof(string), 204)] + public IActionResult GetLessons(int page, int number, LessonOrderCriteria orderCriteria) + { + var nbLesson = _lessonDataService.GetLessons(page, number, orderCriteria).Count(); + if (nbLesson == 0) { - _lessonDataService = lessonDataService; - _logger = logger; + _logger.LogError("[ERREUR] Aucune leçon trouvée."); + return StatusCode(204); } - [HttpGet("lessons/{page:int}/{number:int}/{orderCriteria}")] - [ProducesResponseType(typeof(LessonDto), 200)] - [ProducesResponseType(typeof(string), 204)] - public IActionResult GetLessons(int page, int number, LessonOrderCriteria orderCriteria) - { - var nbLesson = _lessonDataService.GetLessons(page, number, orderCriteria).Count(); - if (nbLesson == 0) - { - _logger.LogError("[ERREUR] Aucune leçon trouvée."); - return StatusCode(204); - } + _logger.LogInformation("[INFORMATION] {nb} Leçon(s) trouvée(s)", nbLesson); + return Ok(_lessonDataService.GetLessons(page, number, orderCriteria)); + } - _logger.LogInformation("[INFORMATION] {nb} Leçon(s) trouvée(s)", nbLesson); - return Ok(_lessonDataService.GetLessons(page, number, orderCriteria)); + [HttpGet("lesson/{id:int}")] + [ProducesResponseType(typeof(LessonDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetLessonById(int id) + { + try + { + _logger.LogInformation("[INFORMATION] La leçon avec l'id {id} a été trouvé.", id); + return Ok(_lessonDataService.GetLessonById(id)); + } + catch (ArgumentException) + { + _logger.LogError("[ERREUR] Aucune leçon trouvée avec l'id {id}.", id); + return NotFound(); } + } - [HttpGet("lesson/{id:int}")] - [ProducesResponseType(typeof(LessonDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetLessonById(int id) + [HttpGet("lesson/{title:alpha}")] + [ProducesResponseType(typeof(LessonDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetLessonByTitle(string title) + { + try { - try - { - _logger.LogInformation("[INFORMATION] La leçon avec l'id {id} a été trouvé.", id); - return Ok(_lessonDataService.GetLessonById(id)); - } - catch (ArgumentException) - { - _logger.LogError("[ERREUR] Aucune leçon trouvée avec l'id {id}.", id); - return NotFound(); - } + _logger.LogInformation("[INFORMATION] La leçon avec le titre {title} a été trouvé.", title); + return Ok(_lessonDataService.GetLessonByTitle(title)); } + catch (ArgumentException) + { + _logger.LogError("[ERREUR] Aucune leçon trouvée avec le titre {title}.", title); + return NotFound(); + } + } - [HttpGet("lesson/{title:alpha}")] - [ProducesResponseType(typeof(LessonDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetLessonByTitle(string title) + [HttpDelete("lesson/{id:int}")] + [ProducesResponseType(typeof(LessonDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult DeleteLesson(int id) + { + var success = _lessonDataService.DeleteLesson(id); + if (success) { - try - { - _logger.LogInformation("[INFORMATION] La leçon avec le titre {title} a été trouvé.", title); - return Ok(_lessonDataService.GetLessonByTitle(title)); - } - catch (ArgumentException) - { - _logger.LogError("[ERREUR] Aucune leçon trouvée avec le titre {title}.", title); - return NotFound(); - } + _logger.LogInformation("[INFORMATION] La leçon avec l'id {id} a été supprimé.", id); + return Ok(_lessonDataService.DeleteLesson(id)); } + else + { + _logger.LogError("[ERREUR] Aucune leçon trouvée avec l'id {id}.", id); + return NotFound(); + } + } - [HttpDelete("lesson/{id:int}")] - [ProducesResponseType(typeof(LessonDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult DeleteLesson(int id) + [HttpPost] + [ProducesResponseType(typeof(LessonDto), 201)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 500)] + public IActionResult CreateLesson([FromBody] LessonDto dto) + { + if (dto.Title == null || dto.LastPublisher == null) + { + return BadRequest(); + } + try { - var success = _lessonDataService.DeleteLesson(id); - if (success) + var createdLesson = _lessonDataService.CreateLesson(dto.Id, dto.Title, dto.LastPublisher, dto.LastEdit ?? DateOnly.FromDateTime(DateTime.Now)); + if (createdLesson != null) { - _logger.LogInformation("[INFORMATION] La leçon avec l'id {id} a été supprimé.", id); - return Ok(_lessonDataService.DeleteLesson(id)); + _logger.LogInformation( + "[INFORMATION] Une leçon a été créé : title - {title}, lastPublisher - {publisher}, lastEdit - {lastEdit}", + dto.Title, dto.LastPublisher, dto.LastEdit); + return Created(nameof(GetLessons), createdLesson); } else { - _logger.LogError("[ERREUR] Aucune leçon trouvée avec l'id {id}.", id); - return NotFound(); + return StatusCode(500); } } - - [HttpPost] - [ProducesResponseType(typeof(LessonDto), 201)] - [ProducesResponseType(typeof(string), 400)] - [ProducesResponseType(typeof(string), 500)] - public IActionResult CreateLesson([FromBody] LessonDto dto) + catch (ArgumentException e) { - if (dto.Title == null || dto.LastPublisher == null) - { - return BadRequest(); - } - try - { - var createdLesson = _lessonDataService.CreateLesson(dto.Id, dto.Title, dto.LastPublisher, dto.LastEdit ?? DateOnly.FromDateTime(DateTime.Now)); - if (createdLesson != null) - { - _logger.LogInformation( - "[INFORMATION] Une leçon a été créé : title - {title}, lastPublisher - {publisher}, lastEdit - {lastEdit}", - dto.Title, dto.LastPublisher, dto.LastEdit); - return Created(nameof(GetLessons), createdLesson); - } - else - { - return StatusCode(500); - } - } - catch (ArgumentException e) - { - _logger.LogError("[ERREUR] " + e.Message); - return Created(); - } + _logger.LogError("[ERREUR] " + e.Message); + return Created(); } + } - [HttpPut("lesson/{id:int}")] - [ProducesResponseType(typeof(LessonDto), 200)] - [ProducesResponseType(typeof(string), 400)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult UpdateLesson(int id, [FromBody] LessonDto LessonDto) + [HttpPut("lesson/{id:int}")] + [ProducesResponseType(typeof(LessonDto), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult UpdateLesson(int id, [FromBody] LessonDto LessonDto) + { + if (id != LessonDto.Id) { - if (id != LessonDto.Id) - { - _logger.LogError("[ERREUR] Problème ID - La mise à jour de la leçon avec l'id {id} a échouée.", id); - return BadRequest(); - } - - if (!ModelState.IsValid) - { - _logger.LogError("[ERREUR] Problème controlleur - La mise à jour de la leçon avec l'id {id} a échouée.", - id); - return BadRequest(); - } - if (LessonDto != null) - { - _logger.LogInformation("[INFORMATION] La mise à jour de la leçon avec l'id {id} a été effectuée", id); - return Ok(_lessonDataService.UpdateLesson(id, LessonDto)); - } + _logger.LogError("[ERREUR] Problème ID - La mise à jour de la leçon avec l'id {id} a échouée.", id); + return BadRequest(); + } - _logger.LogError("[ERREUR] Aucune leçon trouvée avec l'id {id}.", id); - return NotFound(); + if (!ModelState.IsValid) + { + _logger.LogError("[ERREUR] Problème controlleur - La mise à jour de la leçon avec l'id {id} a échouée.", + id); + return BadRequest(); } + if (LessonDto != null) + { + _logger.LogInformation("[INFORMATION] La mise à jour de la leçon avec l'id {id} a été effectuée", id); + return Ok(_lessonDataService.UpdateLesson(id, LessonDto)); + } + + _logger.LogError("[ERREUR] Aucune leçon trouvée avec l'id {id}.", id); + return NotFound(); } } \ No newline at end of file diff --git a/API_SQLuedo/API/Controllers/ParagraphsController.cs b/API_SQLuedo/API/Controllers/ParagraphsController.cs index a8fa71a..a618e85 100644 --- a/API_SQLuedo/API/Controllers/ParagraphsController.cs +++ b/API_SQLuedo/API/Controllers/ParagraphsController.cs @@ -5,139 +5,138 @@ using Model.OrderCriteria; using Shared; using Asp.Versioning; -namespace API.Controllers +namespace API.Controllers; + +[Route("api/v{version:apiVersion}/[controller]")] +[Authorize] +[ApiVersion("1.0")] +[ApiController] +public class ParagraphsController : Controller { - [Route("api/v{version:apiVersion}/[controller]")] - [Authorize] - [ApiVersion("1.0")] - [ApiController] - public class ParagraphsController : Controller - { - private readonly IParagraphService _paragraphDataService; + private readonly IParagraphService _paragraphDataService; + + private readonly ILogger _logger; - private readonly ILogger _logger; + public ParagraphsController(IParagraphService paragraphDataService, + ILogger logger) + { + _paragraphDataService = paragraphDataService; + _logger = logger; + } - public ParagraphsController(IParagraphService paragraphDataService, - ILogger logger) + [HttpGet("paragraphs/{page:int}/{number:int}/{orderCriteria}")] + [ProducesResponseType(typeof(ParagraphDto), 200)] + [ProducesResponseType(typeof(string), 204)] + public IActionResult GetParagraphs(int page, int number, ParagraphOrderCriteria orderCriteria) + { + var nbParagraph = _paragraphDataService.GetParagraphs(page, number, orderCriteria).ToList().Count; + if (nbParagraph == 0) { - _paragraphDataService = paragraphDataService; - _logger = logger; + _logger.LogError("[ERREUR] Aucun paragraphe trouvé."); + return StatusCode(204); } - [HttpGet("paragraphs/{page:int}/{number:int}/{orderCriteria}")] - [ProducesResponseType(typeof(ParagraphDto), 200)] - [ProducesResponseType(typeof(string), 204)] - public IActionResult GetParagraphs(int page, int number, ParagraphOrderCriteria orderCriteria) - { - var nbParagraph = _paragraphDataService.GetParagraphs(page, number, orderCriteria).ToList().Count; - if (nbParagraph == 0) - { - _logger.LogError("[ERREUR] Aucun paragraphe trouvé."); - return StatusCode(204); - } + _logger.LogInformation("[INFORMATION] {nb} Paragraphe(s) trouvé(s)", nbParagraph); + return Ok(_paragraphDataService.GetParagraphs(page, number, orderCriteria)); + } - _logger.LogInformation("[INFORMATION] {nb} Paragraphe(s) trouvé(s)", nbParagraph); - return Ok(_paragraphDataService.GetParagraphs(page, number, orderCriteria)); + [HttpGet("paragraph/{id:int}")] + [ProducesResponseType(typeof(ParagraphDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetParagraphById(int id) + { + try + { + _logger.LogInformation("[INFORMATION] Le paragraphe avec l'id {id} a été trouvé.", id); + return Ok(_paragraphDataService.GetParagraphById(id)); } - - [HttpGet("paragraph/{id:int}")] - [ProducesResponseType(typeof(ParagraphDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetParagraphById(int id) + catch (ArgumentException) { - try - { - _logger.LogInformation("[INFORMATION] Le paragraphe avec l'id {id} a été trouvé.", id); - return Ok(_paragraphDataService.GetParagraphById(id)); - } - catch (ArgumentException) - { - _logger.LogError("[ERREUR] Aucun paragraphe trouvé avec l'id {id}.", id); - return NotFound(); - } + _logger.LogError("[ERREUR] Aucun paragraphe trouvé avec l'id {id}.", id); + return NotFound(); } + } - [HttpGet("paragraph/{title:alpha}")] - [ProducesResponseType(typeof(ParagraphDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetParagraphByTitle(string title) + [HttpGet("paragraph/{title:alpha}")] + [ProducesResponseType(typeof(ParagraphDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetParagraphByTitle(string title) + { + try { - try - { - _logger.LogInformation("[INFORMATION] Le paragraphe avec le titre {title} a été trouvé.", title); - return Ok(_paragraphDataService.GetParagraphByTitle(title)); - } - catch (ArgumentException) - { - _logger.LogError("[ERREUR] Aucun paragraphe trouvé avec le titre {title}.", title); - return NotFound(); - } + _logger.LogInformation("[INFORMATION] Le paragraphe avec le titre {title} a été trouvé.", title); + return Ok(_paragraphDataService.GetParagraphByTitle(title)); } - - [HttpDelete("paragraph/{id:int}")] - [ProducesResponseType(typeof(ParagraphDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult DeleteParagraph(int id) + catch (ArgumentException) { - var success = _paragraphDataService.DeleteParagraph(id); - if (success) - { - _logger.LogInformation("[INFORMATION] Le paragraphe avec l'id {id} a été supprimé.", id); - return Ok(_paragraphDataService.DeleteParagraph(id)); - } - else - { - _logger.LogError("[ERREUR] Aucun paragraphe trouvé avec l'id {id}.", id); - return NotFound(); - } + _logger.LogError("[ERREUR] Aucun paragraphe trouvé avec le titre {title}.", title); + return NotFound(); } + } - [HttpPost] - [ProducesResponseType(typeof(ParagraphDto), 201)] - [ProducesResponseType(typeof(string), 400)] - public IActionResult CreateParagraph([FromBody] ParagraphDto dto) + [HttpDelete("paragraph/{id:int}")] + [ProducesResponseType(typeof(ParagraphDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult DeleteParagraph(int id) + { + var success = _paragraphDataService.DeleteParagraph(id); + if (success) { - if (dto.ContentTitle == null || dto.ContentContent == null || dto.Title == null || dto.Content == null || dto.Info == null || dto.Query == null || - dto.Comment == null) - { - return BadRequest(); - } - - _logger.LogInformation( - "[INFORMATION] Un paragraphe a été créé : title - {title}, content - {content}, info - {info}, query - {query}, comment - {comment}", - dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment); - return Created(nameof(GetParagraphs), - _paragraphDataService.CreateParagraph(dto.ContentTitle, dto.ContentContent,dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment, - dto.LessonId)); + _logger.LogInformation("[INFORMATION] Le paragraphe avec l'id {id} a été supprimé.", id); + return Ok(_paragraphDataService.DeleteParagraph(id)); + } + else + { + _logger.LogError("[ERREUR] Aucun paragraphe trouvé avec l'id {id}.", id); + return NotFound(); } + } - [HttpPut("paragraph/{id:int}")] - [ProducesResponseType(typeof(ParagraphDto), 200)] - [ProducesResponseType(typeof(string), 400)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult UpdateParagraph(int id, [FromBody] ParagraphDto ParagraphDto) + [HttpPost] + [ProducesResponseType(typeof(ParagraphDto), 201)] + [ProducesResponseType(typeof(string), 400)] + public IActionResult CreateParagraph([FromBody] ParagraphDto dto) + { + if (dto.ContentTitle == null || dto.ContentContent == null || dto.Title == null || dto.Content == null || dto.Info == null || dto.Query == null || + dto.Comment == null) { - if (id != ParagraphDto.Id) - { - _logger.LogError("[ERREUR] Problème ID - La mise à jour du paragraphe avec l'id {id} a échouée.", id); - return BadRequest(); - } + return BadRequest(); + } - if (!ModelState.IsValid) - { - _logger.LogError( - "[ERREUR] Problème controlleur - La mise à jour du paragraphe avec l'id {id} a échouée.", id); - return BadRequest(); - } + _logger.LogInformation( + "[INFORMATION] Un paragraphe a été créé : title - {title}, content - {content}, info - {info}, query - {query}, comment - {comment}", + dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment); + return Created(nameof(GetParagraphs), + _paragraphDataService.CreateParagraph(dto.ContentTitle, dto.ContentContent,dto.Title, dto.Content, dto.Info, dto.Query, dto.Comment, + dto.LessonId)); + } - if (ParagraphDto != null) - { - _logger.LogInformation("[INFORMATION] La mise à jour du paragraphe avec l'id {id} a été effectuée", id); - return Ok(_paragraphDataService.UpdateParagraph(id, ParagraphDto)); - } + [HttpPut("paragraph/{id:int}")] + [ProducesResponseType(typeof(ParagraphDto), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult UpdateParagraph(int id, [FromBody] ParagraphDto ParagraphDto) + { + if (id != ParagraphDto.Id) + { + _logger.LogError("[ERREUR] Problème ID - La mise à jour du paragraphe avec l'id {id} a échouée.", id); + return BadRequest(); + } - _logger.LogError("[ERREUR] Aucun paragraphe trouvé avec l'id {id}.", id); - return NotFound(); + if (!ModelState.IsValid) + { + _logger.LogError( + "[ERREUR] Problème controlleur - La mise à jour du paragraphe avec l'id {id} a échouée.", id); + return BadRequest(); } + + if (ParagraphDto != null) + { + _logger.LogInformation("[INFORMATION] La mise à jour du paragraphe avec l'id {id} a été effectuée", id); + return Ok(_paragraphDataService.UpdateParagraph(id, ParagraphDto)); + } + + _logger.LogError("[ERREUR] Aucun paragraphe trouvé avec l'id {id}.", id); + return NotFound(); } } \ No newline at end of file diff --git a/API_SQLuedo/API/Controllers/SuccessesController.cs b/API_SQLuedo/API/Controllers/SuccessesController.cs index 60433c1..9287356 100644 --- a/API_SQLuedo/API/Controllers/SuccessesController.cs +++ b/API_SQLuedo/API/Controllers/SuccessesController.cs @@ -5,203 +5,202 @@ using Model.OrderCriteria; using Shared; using Asp.Versioning; -namespace API.Controllers +namespace API.Controllers; + +[Route("api/v{version:apiVersion}/[controller]")] +[Authorize] +[ApiVersion("1.0")] +[ApiController] +public class SuccessesController : Controller { - [Route("api/v{version:apiVersion}/[controller]")] - [Authorize] - [ApiVersion("1.0")] - [ApiController] - public class SuccessesController : Controller + private readonly ISuccessService _successDataService; + + private readonly ILogger _logger; + + public SuccessesController(ISuccessService successDataService, ILogger logger) + { + _successDataService = successDataService; + _logger = logger; + } + + [HttpGet("successes/{page:int}/{number:int}/{orderCriteria}")] + [ProducesResponseType(typeof(SuccessDto), 200)] + [ProducesResponseType(typeof(string), 204)] + [ProducesResponseType(typeof(string), 400)] + public IActionResult GetSuccesses(int page, int number, SuccessOrderCriteria orderCriteria) + { + if (page < 1 || number < 1) + { + _logger.LogError("[ERREUR] La page ou le nombre de succès est inférieur à 1."); + return BadRequest("La page ou le nombre de succès est inférieur à 1."); + } + + var nbUser = _successDataService.GetSuccesses(page, number, orderCriteria).ToList().Count; + if (nbUser == 0) + { + _logger.LogError("[ERREUR] Aucun Succès trouvé."); + return StatusCode(204); + } + + _logger.LogInformation("[INFORMATION] {nb} Succès(s) trouvé(s)", nbUser); + return Ok(_successDataService.GetSuccesses(page, number, orderCriteria)); + } + + [HttpGet("success/user/{id:int}")] + [ProducesResponseType(typeof(SuccessDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetSuccessByUserId(int id) + { + if (id < 1) + { + _logger.LogError("[ERREUR] L'id de l'utilisateur est inférieur à 1."); + return BadRequest("L'id de l'utilisateur est inférieur à 1."); + } + + try + { + _logger.LogInformation("[INFORMATION] Le succès avec l'id de l'utilisateur {id} a été trouvé.", id); + return Ok(_successDataService.GetSuccessesByUserId(id)); + } + catch (ArgumentException) + { + _logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id de l'utilisateur {id}.", id); + return NotFound("Aucun utilisateur trouvé avec l'id de l'utilisateur."); + } + } + + [HttpGet("success/inquiry/{id:int}")] + [ProducesResponseType(typeof(SuccessDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetSuccessByInquiryId(int id) + { + if (id < 1) + { + _logger.LogError("[ERREUR] L'id de l'enquête doit être inférieur à 1."); + return BadRequest("L'id de l'enquête doit être inférieur à 1."); + } + + try + { + _logger.LogInformation("[INFORMATION] Utilisateur avec l'id de l'enquête {inquiryId} a été trouvé.", + id); + return Ok(_successDataService.GetSuccessesByInquiryId(id)); + } + catch (ArgumentException) + { + _logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id de l'enquête {inquiryId}.", id); + return NotFound("Aucune enquête trouvée avec l'id de l'enquête."); + } + } + + [HttpDelete("success/{idUser:int}/{idInquiry:int}")] + [ProducesResponseType(typeof(SuccessDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult DeleteSuccess(int idUser, int idInquiry) + { + if (idUser < 1 || idInquiry < 1) + { + _logger.LogInformation("[INFORMATION] L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); + return BadRequest("L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); + } + + var success = _successDataService.DeleteSuccess(idUser, idInquiry); + if (success) + { + _logger.LogInformation("[INFORMATION] Le succès avec l'id {id} a été supprimé.", idUser); + return Ok(success); + } + else + { + _logger.LogError("[ERREUR] Aucun succès trouvé avec l'id {id}.", idUser); + return NotFound(); + } + } + + [HttpPost] + [ProducesResponseType(typeof(SuccessDto), 201)] + [ProducesResponseType(typeof(string), 409)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 400)] + public IActionResult CreateSuccess([FromBody] SuccessDto dto) + { + if (dto.UserId < 1 || dto.InquiryId < 1) + { + _logger.LogError("[ERREUR] L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); + return BadRequest("L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); + } + + try + { + var s = _successDataService.CreateSuccess(dto.UserId, dto.InquiryId, dto.IsFinished); + _logger.LogInformation( + "[INFORMATION] Un succès a été créé : userId - {userId}, inquiryId - {inquiryId}, isFinished - {isFinished}", + dto.UserId, dto.InquiryId, dto.IsFinished); + return Created(nameof(GetSuccesses), s); + } + catch (Exception e) + { + return HandleError(e); + } + } + + [HttpPut("success/{idUser:int}/{idInquiry:int}")] + [ProducesResponseType(typeof(SuccessDto), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult UpdateSuccess(int idUser, int idInquiry, [FromBody] SuccessDto successDto) + { + if (idUser < 1 || idInquiry < 1) + { + _logger.LogError("[ERREUR] L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); + return BadRequest("L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); + } + + if (idUser != successDto.UserId || idInquiry != successDto.InquiryId) + { + _logger.LogError( + "[ERREUR] Problème ID - La mise à jour du succès avec l'id de l'utilisateur {id} a échouée.", + idUser); + return BadRequest(); + } + + if (!ModelState.IsValid) + { + _logger.LogError( + "[ERREUR] Problème controlleur - La mise à jour du succès avec l'id de l'utilisateur {id} a échouée.", + idUser); + return BadRequest(); + } + + try + { + var s = _successDataService.UpdateSuccess(idUser, idInquiry, successDto); + _logger.LogInformation( + "[INFORMATION] La mise à jour du succès avec l'id de l'utilisateur {id} a été effectuée", idUser); + return Ok(s); + } + catch (Exception e) + { + return HandleError(e); + } + } + + private IActionResult HandleError(Exception e) { - private readonly ISuccessService _successDataService; - - private readonly ILogger _logger; - - public SuccessesController(ISuccessService successDataService, ILogger logger) - { - _successDataService = successDataService; - _logger = logger; - } - - [HttpGet("successes/{page:int}/{number:int}/{orderCriteria}")] - [ProducesResponseType(typeof(SuccessDto), 200)] - [ProducesResponseType(typeof(string), 204)] - [ProducesResponseType(typeof(string), 400)] - public IActionResult GetSuccesses(int page, int number, SuccessOrderCriteria orderCriteria) - { - if (page < 1 || number < 1) - { - _logger.LogError("[ERREUR] La page ou le nombre de succès est inférieur à 1."); - return BadRequest("La page ou le nombre de succès est inférieur à 1."); - } - - var nbUser = _successDataService.GetSuccesses(page, number, orderCriteria).ToList().Count; - if (nbUser == 0) - { - _logger.LogError("[ERREUR] Aucun Succès trouvé."); - return StatusCode(204); - } - - _logger.LogInformation("[INFORMATION] {nb} Succès(s) trouvé(s)", nbUser); - return Ok(_successDataService.GetSuccesses(page, number, orderCriteria)); - } - - [HttpGet("success/user/{id:int}")] - [ProducesResponseType(typeof(SuccessDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetSuccessByUserId(int id) - { - if (id < 1) - { - _logger.LogError("[ERREUR] L'id de l'utilisateur est inférieur à 1."); - return BadRequest("L'id de l'utilisateur est inférieur à 1."); - } - - try - { - _logger.LogInformation("[INFORMATION] Le succès avec l'id de l'utilisateur {id} a été trouvé.", id); - return Ok(_successDataService.GetSuccessesByUserId(id)); - } - catch (ArgumentException) - { - _logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id de l'utilisateur {id}.", id); - return NotFound("Aucun utilisateur trouvé avec l'id de l'utilisateur."); - } - } - - [HttpGet("success/inquiry/{id:int}")] - [ProducesResponseType(typeof(SuccessDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetSuccessByInquiryId(int id) - { - if (id < 1) - { - _logger.LogError("[ERREUR] L'id de l'enquête doit être inférieur à 1."); - return BadRequest("L'id de l'enquête doit être inférieur à 1."); - } - - try - { - _logger.LogInformation("[INFORMATION] Utilisateur avec l'id de l'enquête {inquiryId} a été trouvé.", - id); - return Ok(_successDataService.GetSuccessesByInquiryId(id)); - } - catch (ArgumentException) - { - _logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id de l'enquête {inquiryId}.", id); - return NotFound("Aucune enquête trouvée avec l'id de l'enquête."); - } - } - - [HttpDelete("success/{idUser:int}/{idInquiry:int}")] - [ProducesResponseType(typeof(SuccessDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult DeleteSuccess(int idUser, int idInquiry) - { - if (idUser < 1 || idInquiry < 1) - { - _logger.LogInformation("[INFORMATION] L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); - return BadRequest("L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); - } - - var success = _successDataService.DeleteSuccess(idUser, idInquiry); - if (success) - { - _logger.LogInformation("[INFORMATION] Le succès avec l'id {id} a été supprimé.", idUser); - return Ok(success); - } - else - { - _logger.LogError("[ERREUR] Aucun succès trouvé avec l'id {id}.", idUser); - return NotFound(); - } - } - - [HttpPost] - [ProducesResponseType(typeof(SuccessDto), 201)] - [ProducesResponseType(typeof(string), 409)] - [ProducesResponseType(typeof(string), 404)] - [ProducesResponseType(typeof(string), 400)] - public IActionResult CreateSuccess([FromBody] SuccessDto dto) - { - if (dto.UserId < 1 || dto.InquiryId < 1) - { - _logger.LogError("[ERREUR] L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); - return BadRequest("L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); - } - - try - { - var s = _successDataService.CreateSuccess(dto.UserId, dto.InquiryId, dto.IsFinished); - _logger.LogInformation( - "[INFORMATION] Un succès a été créé : userId - {userId}, inquiryId - {inquiryId}, isFinished - {isFinished}", - dto.UserId, dto.InquiryId, dto.IsFinished); - return Created(nameof(GetSuccesses), s); - } - catch (Exception e) - { - return HandleError(e); - } - } - - [HttpPut("success/{idUser:int}/{idInquiry:int}")] - [ProducesResponseType(typeof(SuccessDto), 200)] - [ProducesResponseType(typeof(string), 400)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult UpdateSuccess(int idUser, int idInquiry, [FromBody] SuccessDto successDto) - { - if (idUser < 1 || idInquiry < 1) - { - _logger.LogError("[ERREUR] L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); - return BadRequest("L'id de l'utilisateur ou de l'enquête doit être supérieur à 1."); - } - - if (idUser != successDto.UserId || idInquiry != successDto.InquiryId) - { - _logger.LogError( - "[ERREUR] Problème ID - La mise à jour du succès avec l'id de l'utilisateur {id} a échouée.", - idUser); - return BadRequest(); - } - - if (!ModelState.IsValid) - { - _logger.LogError( - "[ERREUR] Problème controlleur - La mise à jour du succès avec l'id de l'utilisateur {id} a échouée.", - idUser); - return BadRequest(); - } - - try - { - var s = _successDataService.UpdateSuccess(idUser, idInquiry, successDto); - _logger.LogInformation( - "[INFORMATION] La mise à jour du succès avec l'id de l'utilisateur {id} a été effectuée", idUser); - return Ok(s); - } - catch (Exception e) - { - return HandleError(e); - } - } - - private IActionResult HandleError(Exception e) - { - switch (e.Message) - { - case { } msg when msg.Contains("userId"): - _logger.LogError("[ERREUR] Impossible de trouver l'utilisateur pour la manipulation du succès"); - return NotFound("Impossible de trouver l'utilisateur pour la manipulation du succès"); - case { } msg when msg.Contains("inquiryId"): - _logger.LogError("[ERREUR] Impossible de trouver l'enquête pour la manipulation du succès"); - return NotFound("Impossible de trouver l'enquête pour la manipulation du succès"); - case { } msg when msg.Contains("success"): - _logger.LogError("[ERREUR] Impossible de manipuler le succès car il n'existe pas"); - return Conflict("Impossible de manipuler le succès car il n'existe pas"); - default: - _logger.LogError("[ERREUR] Erreur inattendue, impossible de manipuler le succès"); - return BadRequest("Erreur inattendue, impossible de manipuler le succès"); - } + switch (e.Message) + { + case { } msg when msg.Contains("userId"): + _logger.LogError("[ERREUR] Impossible de trouver l'utilisateur pour la manipulation du succès"); + return NotFound("Impossible de trouver l'utilisateur pour la manipulation du succès"); + case { } msg when msg.Contains("inquiryId"): + _logger.LogError("[ERREUR] Impossible de trouver l'enquête pour la manipulation du succès"); + return NotFound("Impossible de trouver l'enquête pour la manipulation du succès"); + case { } msg when msg.Contains("success"): + _logger.LogError("[ERREUR] Impossible de manipuler le succès car il n'existe pas"); + return Conflict("Impossible de manipuler le succès car il n'existe pas"); + default: + _logger.LogError("[ERREUR] Erreur inattendue, impossible de manipuler le succès"); + return BadRequest("Erreur inattendue, impossible de manipuler le succès"); } } } \ No newline at end of file diff --git a/API_SQLuedo/API/Controllers/UserController.cs b/API_SQLuedo/API/Controllers/UserController.cs index 0d8a3cc..e80e096 100644 --- a/API_SQLuedo/API/Controllers/UserController.cs +++ b/API_SQLuedo/API/Controllers/UserController.cs @@ -5,194 +5,193 @@ using Microsoft.AspNetCore.Mvc; using Shared; using Model.OrderCriteria; -namespace API.Controllers +namespace API.Controllers; + +[Route("api/v{version:apiVersion}/[controller]")] +[Authorize] +[ApiVersion("1.0")] +[ApiController] +public class UsersController(ILogger logger, IUserService userService) : ControllerBase { - [Route("api/v{version:apiVersion}/[controller]")] - [Authorize] - [ApiVersion("1.0")] - [ApiController] - public class UsersController(ILogger logger, IUserService userService) : ControllerBase + [HttpGet("users/{page:int}/{number:int}")] + [ProducesResponseType(typeof(UserDto), 200)] + [ProducesResponseType(typeof(string), 204)] + public IActionResult GetUsers(int page, int number, UserOrderCriteria orderCriteria) { - [HttpGet("users/{page:int}/{number:int}")] - [ProducesResponseType(typeof(UserDto), 200)] - [ProducesResponseType(typeof(string), 204)] - public IActionResult GetUsers(int page, int number, UserOrderCriteria orderCriteria) - { - var users = userService.GetUsers(page, number, orderCriteria).ToList(); - if (users.Count == 0) - { - logger.LogError("[ERREUR] Aucun utilisateur trouvé."); - return StatusCode(204); - } - - logger.LogInformation("[INFORMATION] {nb} Utilisateur(s) trouvé(s)", users.Count); - return Ok(users); + var users = userService.GetUsers(page, number, orderCriteria).ToList(); + if (users.Count == 0) + { + logger.LogError("[ERREUR] Aucun utilisateur trouvé."); + return StatusCode(204); } - - [HttpGet("users/not-admin/{page:int}/{number:int}")] - [ProducesResponseType(typeof(UserDto), 200)] - [ProducesResponseType(typeof(string), 204)] - public IActionResult GetNotAdminUsers(int page, int number, UserOrderCriteria orderCriteria) - { - var users = userService.GetNotAdminUsers(page, number, orderCriteria).ToList(); - if (users.Count == 0) - { - logger.LogError("[ERREUR] Aucun utilisateur trouvé."); - return StatusCode(204); - } - logger.LogInformation("[INFORMATION] {nb} Utilisateur(s) trouvé(s)", users.Count); - return Ok(users); - } + logger.LogInformation("[INFORMATION] {nb} Utilisateur(s) trouvé(s)", users.Count); + return Ok(users); + } - [HttpGet("users/number")] - [ProducesResponseType(typeof(UserDto), 200)] - [ProducesResponseType(typeof(string), 204)] - public IActionResult GetNumberOfUsers() - { - var users = userService.GetNumberOfUsers(); - if (users == 0) - { - logger.LogError("[ERREUR] Aucun utilisateur trouvé."); - return StatusCode(204); - } + [HttpGet("users/not-admin/{page:int}/{number:int}")] + [ProducesResponseType(typeof(UserDto), 200)] + [ProducesResponseType(typeof(string), 204)] + public IActionResult GetNotAdminUsers(int page, int number, UserOrderCriteria orderCriteria) + { + var users = userService.GetNotAdminUsers(page, number, orderCriteria).ToList(); + if (users.Count == 0) + { + logger.LogError("[ERREUR] Aucun utilisateur trouvé."); + return StatusCode(204); + } - logger.LogInformation("[INFORMATION] {users} Utilisateur(s) trouvé(s)", users); - return Ok(new KeyValuePair("nbUsers", users)); + logger.LogInformation("[INFORMATION] {nb} Utilisateur(s) trouvé(s)", users.Count); + return Ok(users); + } + + [HttpGet("users/number")] + [ProducesResponseType(typeof(UserDto), 200)] + [ProducesResponseType(typeof(string), 204)] + public IActionResult GetNumberOfUsers() + { + var users = userService.GetNumberOfUsers(); + if (users == 0) + { + logger.LogError("[ERREUR] Aucun utilisateur trouvé."); + return StatusCode(204); } - [HttpGet("user/{id:int}")] - [ProducesResponseType(typeof(UserDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetUserById(int id) - { - try - { - logger.LogInformation("[INFORMATION] Utilisateur avec l'id {id} a été trouvé.", id); - return Ok(userService.GetUserById(id)); - } - catch (ArgumentException) - { - logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id {id}.", id); - return NotFound(); - } + logger.LogInformation("[INFORMATION] {users} Utilisateur(s) trouvé(s)", users); + return Ok(new KeyValuePair("nbUsers", users)); + } + + [HttpGet("user/{id:int}")] + [ProducesResponseType(typeof(UserDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetUserById(int id) + { + try + { + logger.LogInformation("[INFORMATION] Utilisateur avec l'id {id} a été trouvé.", id); + return Ok(userService.GetUserById(id)); + } + catch (ArgumentException) + { + logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id {id}.", id); + return NotFound(); } + } - [HttpGet("user/{username:alpha}")] - [ProducesResponseType(typeof(UserDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetUserByUsername(string username) - { - try - { - logger.LogInformation("[INFORMATION] Utilisateur avec l'username {username} a été trouvé.", username); - return Ok(userService.GetUserByUsername(username)); - } - catch (ArgumentException) - { - logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'username {username}.", username); - return NotFound("Utilisateur non trouvé !"); - } - } - [HttpGet("user/email/{email}")] - [ProducesResponseType(typeof(UserDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult GetByEmail(string email) - { - try - { - logger.LogInformation("[INFORMATION] Utilisateur avec l'username {email} a été trouvé.", email); - return Ok(userService.GetUserByEmail(email)); - } - catch (ArgumentException) - { - logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'username {email}.", email); - return NotFound(); - } + [HttpGet("user/{username:alpha}")] + [ProducesResponseType(typeof(UserDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetUserByUsername(string username) + { + try + { + logger.LogInformation("[INFORMATION] Utilisateur avec l'username {username} a été trouvé.", username); + return Ok(userService.GetUserByUsername(username)); + } + catch (ArgumentException) + { + logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'username {username}.", username); + return NotFound("Utilisateur non trouvé !"); + } + } + [HttpGet("user/email/{email}")] + [ProducesResponseType(typeof(UserDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult GetByEmail(string email) + { + try + { + logger.LogInformation("[INFORMATION] Utilisateur avec l'username {email} a été trouvé.", email); + return Ok(userService.GetUserByEmail(email)); } + catch (ArgumentException) + { + logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'username {email}.", email); + return NotFound(); + } + } - [HttpDelete("user/{id:int}")] - [ProducesResponseType(typeof(UserDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult DeleteUser(int id) - { - var success = userService.DeleteUser(id); - if (success) - { - logger.LogInformation("[INFORMATION] L'utilisateur avec l'id {id} a été supprimé.", id); - return Ok(); - } - else - { - logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id {id}.", id); - return NotFound(); - } + [HttpDelete("user/{id:int}")] + [ProducesResponseType(typeof(UserDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult DeleteUser(int id) + { + var success = userService.DeleteUser(id); + if (success) + { + logger.LogInformation("[INFORMATION] L'utilisateur avec l'id {id} a été supprimé.", id); + return Ok(); } + else + { + logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id {id}.", id); + return NotFound(); + } + } - [HttpDelete("user/username/{username:alpha}")] - [ProducesResponseType(typeof(UserDto), 200)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult DeleteUserByUsername(string username) - { - var success = userService.DeleteUserByUsername(username); - if (success) - { - logger.LogInformation("[INFORMATION] L'utilisateur avec le pseudo {username} a été supprimé.", username); - return Ok(); - } - else - { - logger.LogError("[ERREUR] Aucun utilisateur trouvé avec le pseudo {username}.", username); - return NotFound(); - } + [HttpDelete("user/username/{username:alpha}")] + [ProducesResponseType(typeof(UserDto), 200)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult DeleteUserByUsername(string username) + { + var success = userService.DeleteUserByUsername(username); + if (success) + { + logger.LogInformation("[INFORMATION] L'utilisateur avec le pseudo {username} a été supprimé.", username); + return Ok(); } + else + { + logger.LogError("[ERREUR] Aucun utilisateur trouvé avec le pseudo {username}.", username); + return NotFound(); + } + } - [HttpPost] - [ProducesResponseType(typeof(UserDto), 201)] - [ProducesResponseType(typeof(string), 400)] - public IActionResult CreateUser([FromBody] UserDto dto) - { - if (dto.Username == null || dto.Password == null || dto.Email == null) - { - return BadRequest(); - } - - // return Ok(userService.CreateUser(username, password, email, isAdmin)); - logger.LogInformation( - "[INFORMATION] Un utilisateur a été créé : username - {username}, password - {password}, email - {email}, isAdmin - {isAdmin}", - dto.Username, dto.Password, dto.Email, dto.IsAdmin); - return Created(nameof(GetUsers), - userService.CreateUser(dto.Username, dto.Password, dto.Email, dto.IsAdmin)); + [HttpPost] + [ProducesResponseType(typeof(UserDto), 201)] + [ProducesResponseType(typeof(string), 400)] + public IActionResult CreateUser([FromBody] UserDto dto) + { + if (dto.Username == null || dto.Password == null || dto.Email == null) + { + return BadRequest(); } - [HttpPut("user/{id:int}")] - [ProducesResponseType(typeof(UserDto), 200)] - [ProducesResponseType(typeof(string), 400)] - [ProducesResponseType(typeof(string), 404)] - public IActionResult UpdateUser(int id, [FromBody] UserDto UserDto) - { - if (id != UserDto.Id) - { - logger.LogError("[ERREUR] Problème ID - La mise à jour de l'utilisateur avec l'id {id} a échouée.", id); - return BadRequest(); - } + // return Ok(userService.CreateUser(username, password, email, isAdmin)); + logger.LogInformation( + "[INFORMATION] Un utilisateur a été créé : username - {username}, password - {password}, email - {email}, isAdmin - {isAdmin}", + dto.Username, dto.Password, dto.Email, dto.IsAdmin); + return Created(nameof(GetUsers), + userService.CreateUser(dto.Username, dto.Password, dto.Email, dto.IsAdmin)); + } - if (!ModelState.IsValid) - { - logger.LogError( - "[ERREUR] Problème controller - La mise à jour de l'utilisateur avec l'id {id} a échouée.", id); - return BadRequest(); - } + [HttpPut("user/{id:int}")] + [ProducesResponseType(typeof(UserDto), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + public IActionResult UpdateUser(int id, [FromBody] UserDto UserDto) + { + if (id != UserDto.Id) + { + logger.LogError("[ERREUR] Problème ID - La mise à jour de l'utilisateur avec l'id {id} a échouée.", id); + return BadRequest(); + } - if (UserDto != null) - { - logger.LogInformation("[INFORMATION] La mise à jour de l'utilisateur avec l'id {id} a été effectuée", - id); - return Ok(userService.UpdateUser(id, UserDto)); - } + if (!ModelState.IsValid) + { + logger.LogError( + "[ERREUR] Problème controller - La mise à jour de l'utilisateur avec l'id {id} a échouée.", id); + return BadRequest(); + } - logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id {id}.", id); - return NotFound(); + if (UserDto != null) + { + logger.LogInformation("[INFORMATION] La mise à jour de l'utilisateur avec l'id {id} a été effectuée", + id); + return Ok(userService.UpdateUser(id, UserDto)); } + + logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id {id}.", id); + return NotFound(); } } \ No newline at end of file From a15752d650b4573b7f14583d33ea0dff37b3c36d Mon Sep 17 00:00:00 2001 From: Nestisse Date: Wed, 3 Apr 2024 08:59:33 +0200 Subject: [PATCH 75/78] Ajout nouvelle migration --- .../20240402175009_prod.Designer.cs | 595 ------------------ .../Migrations/20240402175009_prod.cs | 452 ------------- .../Migrations/UserDbContextModelSnapshot.cs | 592 ----------------- 3 files changed, 1639 deletions(-) delete mode 100644 API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.Designer.cs delete mode 100644 API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.cs delete mode 100644 API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs diff --git a/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.Designer.cs b/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.Designer.cs deleted file mode 100644 index 692d7b4..0000000 --- a/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.Designer.cs +++ /dev/null @@ -1,595 +0,0 @@ -// -using System; -using DbContextLib; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace DbContextLib.Migrations -{ - [DbContext(typeof(UserDbContext))] - [Migration("20240402175009_prod")] - partial class prod - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.HasSequence("ContentLessonEntitySequence"); - - modelBuilder.Entity("Entities.BlackListEntity", b => - { - b.Property("Email") - .HasColumnType("text"); - - b.Property("ExpirationDate") - .HasColumnType("date"); - - b.HasKey("Email"); - - b.ToTable("BlackList"); - }); - - modelBuilder.Entity("Entities.ContentLessonEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasDefaultValueSql("nextval('\"ContentLessonEntitySequence\"')"); - - NpgsqlPropertyBuilderExtensions.UseSequence(b.Property("Id")); - - b.Property("ContentContent") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContentTitle") - .IsRequired() - .HasColumnType("text"); - - b.Property("LessonId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("LessonId"); - - b.ToTable((string)null); - - b.UseTpcMappingStrategy(); - }); - - modelBuilder.Entity("Entities.InquiryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsUser") - .HasColumnType("boolean"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Inquiries"); - }); - - modelBuilder.Entity("Entities.InquiryTableEntity", b => - { - b.Property("OwnerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - b.Property("ConnectionInfo") - .IsRequired() - .HasColumnType("text"); - - b.Property("DatabaseName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("OwnerId"); - - b.ToTable("InquiryTable"); - }); - - modelBuilder.Entity("Entities.LessonEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("LastEdit") - .HasColumnType("date"); - - b.Property("LastPublisher") - .IsRequired() - .HasColumnType("text"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Lesson"); - }); - - modelBuilder.Entity("Entities.NotepadEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("InquiryId") - .HasColumnType("integer"); - - b.Property("Notes") - .IsRequired() - .HasColumnType("text"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("InquiryId"); - - b.HasIndex("UserId"); - - b.ToTable("Notepad"); - }); - - modelBuilder.Entity("Entities.SolutionEntity", b => - { - b.Property("OwnerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - b.Property("Explaination") - .IsRequired() - .HasColumnType("text"); - - b.Property("MurderPlace") - .IsRequired() - .HasColumnType("text"); - - b.Property("MurderWeapon") - .IsRequired() - .HasColumnType("text"); - - b.Property("MurdererFirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("MurdererLastName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("OwnerId"); - - b.ToTable("Solution"); - }); - - modelBuilder.Entity("Entities.SuccessEntity", b => - { - b.Property("InquiryId") - .HasColumnType("integer"); - - b.Property("IsFinished") - .HasColumnType("boolean"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.HasKey("InquiryId"); - - b.HasIndex("UserId"); - - b.ToTable("Success"); - }); - - modelBuilder.Entity("Entities.UserEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsAdmin") - .HasColumnType("boolean"); - - b.Property("Password") - .IsRequired() - .HasColumnType("text"); - - b.Property("Username") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("User"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("text"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Entities.ParagraphEntity", b => - { - b.HasBaseType("Entities.ContentLessonEntity"); - - b.Property("Comment") - .IsRequired() - .HasColumnType("text"); - - b.Property("Content") - .IsRequired() - .HasColumnType("text"); - - b.Property("Info") - .IsRequired() - .HasColumnType("text"); - - b.Property("Query") - .IsRequired() - .HasColumnType("text"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.ToTable("Paragraph"); - }); - - modelBuilder.Entity("Entities.ContentLessonEntity", b => - { - b.HasOne("Entities.LessonEntity", "Lesson") - .WithMany("Content") - .HasForeignKey("LessonId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Lesson"); - }); - - modelBuilder.Entity("Entities.InquiryTableEntity", b => - { - b.HasOne("Entities.InquiryEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Entities.NotepadEntity", b => - { - b.HasOne("Entities.InquiryEntity", "Inquiry") - .WithMany() - .HasForeignKey("InquiryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Entities.UserEntity", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Inquiry"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Entities.SolutionEntity", b => - { - b.HasOne("Entities.InquiryEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Entities.SuccessEntity", b => - { - b.HasOne("Entities.InquiryEntity", "Inquiry") - .WithMany() - .HasForeignKey("InquiryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Entities.UserEntity", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Inquiry"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Entities.LessonEntity", b => - { - b.Navigation("Content"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.cs b/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.cs deleted file mode 100644 index 7543a7e..0000000 --- a/API_SQLuedo/DbContextLib/Migrations/20240402175009_prod.cs +++ /dev/null @@ -1,452 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace DbContextLib.Migrations -{ - /// - public partial class prod : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateSequence( - name: "ContentLessonEntitySequence"); - - migrationBuilder.CreateTable( - name: "AspNetRoles", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetUsers", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - EmailConfirmed = table.Column(type: "boolean", nullable: false), - PasswordHash = table.Column(type: "text", nullable: true), - SecurityStamp = table.Column(type: "text", nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true), - PhoneNumber = table.Column(type: "text", nullable: true), - PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), - TwoFactorEnabled = table.Column(type: "boolean", nullable: false), - LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), - LockoutEnabled = table.Column(type: "boolean", nullable: false), - AccessFailedCount = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "BlackList", - columns: table => new - { - Email = table.Column(type: "text", nullable: false), - ExpirationDate = table.Column(type: "date", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BlackList", x => x.Email); - }); - - migrationBuilder.CreateTable( - name: "Inquiries", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Title = table.Column(type: "text", nullable: false), - Description = table.Column(type: "text", nullable: false), - IsUser = table.Column(type: "boolean", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Inquiries", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Lesson", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Title = table.Column(type: "text", nullable: false), - LastPublisher = table.Column(type: "text", nullable: false), - LastEdit = table.Column(type: "date", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Lesson", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "User", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Username = table.Column(type: "text", nullable: false), - Password = table.Column(type: "text", nullable: false), - Email = table.Column(type: "text", nullable: false), - IsAdmin = table.Column(type: "boolean", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_User", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AspNetRoleClaims", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RoleId = table.Column(type: "text", nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserClaims", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - UserId = table.Column(type: "text", nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUserClaims_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserLogins", - columns: table => new - { - LoginProvider = table.Column(type: "text", nullable: false), - ProviderKey = table.Column(type: "text", nullable: false), - ProviderDisplayName = table.Column(type: "text", nullable: true), - UserId = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); - table.ForeignKey( - name: "FK_AspNetUserLogins_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserRoles", - columns: table => new - { - UserId = table.Column(type: "text", nullable: false), - RoleId = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AspNetUserTokens", - columns: table => new - { - UserId = table.Column(type: "text", nullable: false), - LoginProvider = table.Column(type: "text", nullable: false), - Name = table.Column(type: "text", nullable: false), - Value = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AspNetUserTokens_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "InquiryTable", - columns: table => new - { - OwnerId = table.Column(type: "integer", nullable: false), - DatabaseName = table.Column(type: "text", nullable: false), - ConnectionInfo = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_InquiryTable", x => x.OwnerId); - table.ForeignKey( - name: "FK_InquiryTable_Inquiries_OwnerId", - column: x => x.OwnerId, - principalTable: "Inquiries", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Solution", - columns: table => new - { - OwnerId = table.Column(type: "integer", nullable: false), - MurdererFirstName = table.Column(type: "text", nullable: false), - MurdererLastName = table.Column(type: "text", nullable: false), - MurderPlace = table.Column(type: "text", nullable: false), - MurderWeapon = table.Column(type: "text", nullable: false), - Explaination = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Solution", x => x.OwnerId); - table.ForeignKey( - name: "FK_Solution_Inquiries_OwnerId", - column: x => x.OwnerId, - principalTable: "Inquiries", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Paragraph", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false, defaultValueSql: "nextval('\"ContentLessonEntitySequence\"')"), - ContentContent = table.Column(type: "text", nullable: false), - ContentTitle = table.Column(type: "text", nullable: false), - LessonId = table.Column(type: "integer", nullable: false), - Title = table.Column(type: "text", nullable: false), - Content = table.Column(type: "text", nullable: false), - Info = table.Column(type: "text", nullable: false), - Query = table.Column(type: "text", nullable: false), - Comment = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Paragraph", x => x.Id); - table.ForeignKey( - name: "FK_Paragraph_Lesson_LessonId", - column: x => x.LessonId, - principalTable: "Lesson", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Notepad", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - UserId = table.Column(type: "integer", nullable: false), - InquiryId = table.Column(type: "integer", nullable: false), - Notes = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Notepad", x => x.Id); - table.ForeignKey( - name: "FK_Notepad_Inquiries_InquiryId", - column: x => x.InquiryId, - principalTable: "Inquiries", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Notepad_User_UserId", - column: x => x.UserId, - principalTable: "User", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Success", - columns: table => new - { - InquiryId = table.Column(type: "integer", nullable: false), - UserId = table.Column(type: "integer", nullable: false), - IsFinished = table.Column(type: "boolean", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Success", x => x.InquiryId); - table.ForeignKey( - name: "FK_Success_Inquiries_InquiryId", - column: x => x.InquiryId, - principalTable: "Inquiries", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Success_User_UserId", - column: x => x.UserId, - principalTable: "User", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_AspNetRoleClaims_RoleId", - table: "AspNetRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "AspNetRoles", - column: "NormalizedName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserClaims_UserId", - table: "AspNetUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserLogins_UserId", - table: "AspNetUserLogins", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AspNetUserRoles_RoleId", - table: "AspNetUserRoles", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - table: "AspNetUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - table: "AspNetUsers", - column: "NormalizedUserName", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Notepad_InquiryId", - table: "Notepad", - column: "InquiryId"); - - migrationBuilder.CreateIndex( - name: "IX_Notepad_UserId", - table: "Notepad", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_Paragraph_LessonId", - table: "Paragraph", - column: "LessonId"); - - migrationBuilder.CreateIndex( - name: "IX_Success_UserId", - table: "Success", - column: "UserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AspNetRoleClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserClaims"); - - migrationBuilder.DropTable( - name: "AspNetUserLogins"); - - migrationBuilder.DropTable( - name: "AspNetUserRoles"); - - migrationBuilder.DropTable( - name: "AspNetUserTokens"); - - migrationBuilder.DropTable( - name: "BlackList"); - - migrationBuilder.DropTable( - name: "InquiryTable"); - - migrationBuilder.DropTable( - name: "Notepad"); - - migrationBuilder.DropTable( - name: "Paragraph"); - - migrationBuilder.DropTable( - name: "Solution"); - - migrationBuilder.DropTable( - name: "Success"); - - migrationBuilder.DropTable( - name: "AspNetRoles"); - - migrationBuilder.DropTable( - name: "AspNetUsers"); - - migrationBuilder.DropTable( - name: "Lesson"); - - migrationBuilder.DropTable( - name: "Inquiries"); - - migrationBuilder.DropTable( - name: "User"); - - migrationBuilder.DropSequence( - name: "ContentLessonEntitySequence"); - } - } -} diff --git a/API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs b/API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs deleted file mode 100644 index 50a98ac..0000000 --- a/API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs +++ /dev/null @@ -1,592 +0,0 @@ -// -using System; -using DbContextLib; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace DbContextLib.Migrations -{ - [DbContext(typeof(UserDbContext))] - partial class UserDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.HasSequence("ContentLessonEntitySequence"); - - modelBuilder.Entity("Entities.BlackListEntity", b => - { - b.Property("Email") - .HasColumnType("text"); - - b.Property("ExpirationDate") - .HasColumnType("date"); - - b.HasKey("Email"); - - b.ToTable("BlackList"); - }); - - modelBuilder.Entity("Entities.ContentLessonEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasDefaultValueSql("nextval('\"ContentLessonEntitySequence\"')"); - - NpgsqlPropertyBuilderExtensions.UseSequence(b.Property("Id")); - - b.Property("ContentContent") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContentTitle") - .IsRequired() - .HasColumnType("text"); - - b.Property("LessonId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("LessonId"); - - b.ToTable((string)null); - - b.UseTpcMappingStrategy(); - }); - - modelBuilder.Entity("Entities.InquiryEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsUser") - .HasColumnType("boolean"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Inquiries"); - }); - - modelBuilder.Entity("Entities.InquiryTableEntity", b => - { - b.Property("OwnerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - b.Property("ConnectionInfo") - .IsRequired() - .HasColumnType("text"); - - b.Property("DatabaseName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("OwnerId"); - - b.ToTable("InquiryTable"); - }); - - modelBuilder.Entity("Entities.LessonEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("LastEdit") - .HasColumnType("date"); - - b.Property("LastPublisher") - .IsRequired() - .HasColumnType("text"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Lesson"); - }); - - modelBuilder.Entity("Entities.NotepadEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("InquiryId") - .HasColumnType("integer"); - - b.Property("Notes") - .IsRequired() - .HasColumnType("text"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("InquiryId"); - - b.HasIndex("UserId"); - - b.ToTable("Notepad"); - }); - - modelBuilder.Entity("Entities.SolutionEntity", b => - { - b.Property("OwnerId") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - b.Property("Explaination") - .IsRequired() - .HasColumnType("text"); - - b.Property("MurderPlace") - .IsRequired() - .HasColumnType("text"); - - b.Property("MurderWeapon") - .IsRequired() - .HasColumnType("text"); - - b.Property("MurdererFirstName") - .IsRequired() - .HasColumnType("text"); - - b.Property("MurdererLastName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("OwnerId"); - - b.ToTable("Solution"); - }); - - modelBuilder.Entity("Entities.SuccessEntity", b => - { - b.Property("InquiryId") - .HasColumnType("integer"); - - b.Property("IsFinished") - .HasColumnType("boolean"); - - b.Property("UserId") - .HasColumnType("integer"); - - b.HasKey("InquiryId"); - - b.HasIndex("UserId"); - - b.ToTable("Success"); - }); - - modelBuilder.Entity("Entities.UserEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsAdmin") - .HasColumnType("boolean"); - - b.Property("Password") - .IsRequired() - .HasColumnType("text"); - - b.Property("Username") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("User"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("text"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Entities.ParagraphEntity", b => - { - b.HasBaseType("Entities.ContentLessonEntity"); - - b.Property("Comment") - .IsRequired() - .HasColumnType("text"); - - b.Property("Content") - .IsRequired() - .HasColumnType("text"); - - b.Property("Info") - .IsRequired() - .HasColumnType("text"); - - b.Property("Query") - .IsRequired() - .HasColumnType("text"); - - b.Property("Title") - .IsRequired() - .HasColumnType("text"); - - b.ToTable("Paragraph"); - }); - - modelBuilder.Entity("Entities.ContentLessonEntity", b => - { - b.HasOne("Entities.LessonEntity", "Lesson") - .WithMany("Content") - .HasForeignKey("LessonId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Lesson"); - }); - - modelBuilder.Entity("Entities.InquiryTableEntity", b => - { - b.HasOne("Entities.InquiryEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Entities.NotepadEntity", b => - { - b.HasOne("Entities.InquiryEntity", "Inquiry") - .WithMany() - .HasForeignKey("InquiryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Entities.UserEntity", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Inquiry"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Entities.SolutionEntity", b => - { - b.HasOne("Entities.InquiryEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Entities.SuccessEntity", b => - { - b.HasOne("Entities.InquiryEntity", "Inquiry") - .WithMany() - .HasForeignKey("InquiryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Entities.UserEntity", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Inquiry"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Entities.LessonEntity", b => - { - b.Navigation("Content"); - }); -#pragma warning restore 612, 618 - } - } -} From 2c802739b00d6b9ccf0ff0ced7075ce1428fef97 Mon Sep 17 00:00:00 2001 From: Clement CHIEU Date: Wed, 3 Apr 2024 09:02:09 +0200 Subject: [PATCH 76/78] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index cee2737..9a39c5b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -90,4 +90,4 @@ steps: CODEFIRST_CLIENTDRONE_ENV_DB_DATABASE: from_secret: db_database ADMINS: erwanmenager,maximesapountzis,johnnyratton,victorgaborit,clementchieu - depends_on: [ api-image-build-and-push ] \ No newline at end of file + depends_on: [ api-image-build-and-push, deploy-sqluedo-db ] \ No newline at end of file From 1aafe248cd7fc9257804589298b775a77387c103 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Wed, 3 Apr 2024 09:05:15 +0200 Subject: [PATCH 77/78] Nouvelle migration de test --- .../Migrations/20240403065352_v1.Designer.cs | 595 ++++++++++++++++++ .../Migrations/20240403065352_v1.cs | 452 +++++++++++++ .../Migrations/UserDbContextModelSnapshot.cs | 592 +++++++++++++++++ 3 files changed, 1639 insertions(+) create mode 100644 API_SQLuedo/DbContextLib/Migrations/20240403065352_v1.Designer.cs create mode 100644 API_SQLuedo/DbContextLib/Migrations/20240403065352_v1.cs create mode 100644 API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs diff --git a/API_SQLuedo/DbContextLib/Migrations/20240403065352_v1.Designer.cs b/API_SQLuedo/DbContextLib/Migrations/20240403065352_v1.Designer.cs new file mode 100644 index 0000000..9ae0bf5 --- /dev/null +++ b/API_SQLuedo/DbContextLib/Migrations/20240403065352_v1.Designer.cs @@ -0,0 +1,595 @@ +// +using System; +using DbContextLib; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DbContextLib.Migrations +{ + [DbContext(typeof(UserDbContext))] + [Migration("20240403065352_v1")] + partial class v1 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.HasSequence("ContentLessonEntitySequence"); + + modelBuilder.Entity("Entities.BlackListEntity", b => + { + b.Property("Email") + .HasColumnType("text"); + + b.Property("ExpirationDate") + .HasColumnType("date"); + + b.HasKey("Email"); + + b.ToTable("BlackList"); + }); + + modelBuilder.Entity("Entities.ContentLessonEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValueSql("nextval('\"ContentLessonEntitySequence\"')"); + + NpgsqlPropertyBuilderExtensions.UseSequence(b.Property("Id")); + + b.Property("ContentContent") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContentTitle") + .IsRequired() + .HasColumnType("text"); + + b.Property("LessonId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("LessonId"); + + b.ToTable((string)null); + + b.UseTpcMappingStrategy(); + }); + + modelBuilder.Entity("Entities.InquiryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsUser") + .HasColumnType("boolean"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Inquiries"); + }); + + modelBuilder.Entity("Entities.InquiryTableEntity", b => + { + b.Property("OwnerId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + b.Property("ConnectionInfo") + .IsRequired() + .HasColumnType("text"); + + b.Property("DatabaseName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("OwnerId"); + + b.ToTable("InquiryTable"); + }); + + modelBuilder.Entity("Entities.LessonEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LastEdit") + .HasColumnType("date"); + + b.Property("LastPublisher") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Lesson"); + }); + + modelBuilder.Entity("Entities.NotepadEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("InquiryId") + .HasColumnType("integer"); + + b.Property("Notes") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InquiryId"); + + b.HasIndex("UserId"); + + b.ToTable("Notepad"); + }); + + modelBuilder.Entity("Entities.SolutionEntity", b => + { + b.Property("OwnerId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + b.Property("Explaination") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurderPlace") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurderWeapon") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurdererFirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurdererLastName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("OwnerId"); + + b.ToTable("Solution"); + }); + + modelBuilder.Entity("Entities.SuccessEntity", b => + { + b.Property("InquiryId") + .HasColumnType("integer"); + + b.Property("IsFinished") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("InquiryId"); + + b.HasIndex("UserId"); + + b.ToTable("Success"); + }); + + modelBuilder.Entity("Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsAdmin") + .HasColumnType("boolean"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Entities.ParagraphEntity", b => + { + b.HasBaseType("Entities.ContentLessonEntity"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("Info") + .IsRequired() + .HasColumnType("text"); + + b.Property("Query") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.ToTable("Paragraph"); + }); + + modelBuilder.Entity("Entities.ContentLessonEntity", b => + { + b.HasOne("Entities.LessonEntity", "Lesson") + .WithMany("Content") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("Entities.InquiryTableEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Entities.NotepadEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Inquiry") + .WithMany() + .HasForeignKey("InquiryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.UserEntity", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Inquiry"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Entities.SolutionEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Entities.SuccessEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Inquiry") + .WithMany() + .HasForeignKey("InquiryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.UserEntity", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Inquiry"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entities.LessonEntity", b => + { + b.Navigation("Content"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/API_SQLuedo/DbContextLib/Migrations/20240403065352_v1.cs b/API_SQLuedo/DbContextLib/Migrations/20240403065352_v1.cs new file mode 100644 index 0000000..a6073c6 --- /dev/null +++ b/API_SQLuedo/DbContextLib/Migrations/20240403065352_v1.cs @@ -0,0 +1,452 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DbContextLib.Migrations +{ + /// + public partial class v1 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateSequence( + name: "ContentLessonEntitySequence"); + + migrationBuilder.CreateTable( + name: "AspNetRoles", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetUsers", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "boolean", nullable: false), + PasswordHash = table.Column(type: "text", nullable: true), + SecurityStamp = table.Column(type: "text", nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true), + PhoneNumber = table.Column(type: "text", nullable: true), + PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), + TwoFactorEnabled = table.Column(type: "boolean", nullable: false), + LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), + LockoutEnabled = table.Column(type: "boolean", nullable: false), + AccessFailedCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "BlackList", + columns: table => new + { + Email = table.Column(type: "text", nullable: false), + ExpirationDate = table.Column(type: "date", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BlackList", x => x.Email); + }); + + migrationBuilder.CreateTable( + name: "Inquiries", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Title = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + IsUser = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Inquiries", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Lesson", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Title = table.Column(type: "text", nullable: false), + LastPublisher = table.Column(type: "text", nullable: false), + LastEdit = table.Column(type: "date", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Lesson", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "User", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Username = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false), + Email = table.Column(type: "text", nullable: false), + IsAdmin = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_User", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AspNetRoleClaims", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "text", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserClaims", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "text", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetUserClaims_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserLogins", + columns: table => new + { + LoginProvider = table.Column(type: "text", nullable: false), + ProviderKey = table.Column(type: "text", nullable: false), + ProviderDisplayName = table.Column(type: "text", nullable: true), + UserId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_AspNetUserLogins_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserRoles", + columns: table => new + { + UserId = table.Column(type: "text", nullable: false), + RoleId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AspNetUserTokens", + columns: table => new + { + UserId = table.Column(type: "text", nullable: false), + LoginProvider = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AspNetUserTokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "InquiryTable", + columns: table => new + { + OwnerId = table.Column(type: "integer", nullable: false), + DatabaseName = table.Column(type: "text", nullable: false), + ConnectionInfo = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InquiryTable", x => x.OwnerId); + table.ForeignKey( + name: "FK_InquiryTable_Inquiries_OwnerId", + column: x => x.OwnerId, + principalTable: "Inquiries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Solution", + columns: table => new + { + OwnerId = table.Column(type: "integer", nullable: false), + MurdererFirstName = table.Column(type: "text", nullable: false), + MurdererLastName = table.Column(type: "text", nullable: false), + MurderPlace = table.Column(type: "text", nullable: false), + MurderWeapon = table.Column(type: "text", nullable: false), + Explaination = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Solution", x => x.OwnerId); + table.ForeignKey( + name: "FK_Solution_Inquiries_OwnerId", + column: x => x.OwnerId, + principalTable: "Inquiries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Paragraph", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false, defaultValueSql: "nextval('\"ContentLessonEntitySequence\"')"), + ContentContent = table.Column(type: "text", nullable: false), + ContentTitle = table.Column(type: "text", nullable: false), + LessonId = table.Column(type: "integer", nullable: false), + Title = table.Column(type: "text", nullable: false), + Content = table.Column(type: "text", nullable: false), + Info = table.Column(type: "text", nullable: false), + Query = table.Column(type: "text", nullable: false), + Comment = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Paragraph", x => x.Id); + table.ForeignKey( + name: "FK_Paragraph_Lesson_LessonId", + column: x => x.LessonId, + principalTable: "Lesson", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Notepad", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "integer", nullable: false), + InquiryId = table.Column(type: "integer", nullable: false), + Notes = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Notepad", x => x.Id); + table.ForeignKey( + name: "FK_Notepad_Inquiries_InquiryId", + column: x => x.InquiryId, + principalTable: "Inquiries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Notepad_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Success", + columns: table => new + { + InquiryId = table.Column(type: "integer", nullable: false), + UserId = table.Column(type: "integer", nullable: false), + IsFinished = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Success", x => x.InquiryId); + table.ForeignKey( + name: "FK_Success_Inquiries_InquiryId", + column: x => x.InquiryId, + principalTable: "Inquiries", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Success_User_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AspNetRoleClaims_RoleId", + table: "AspNetRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + table: "AspNetRoles", + column: "NormalizedName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserClaims_UserId", + table: "AspNetUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserLogins_UserId", + table: "AspNetUserLogins", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AspNetUserRoles_RoleId", + table: "AspNetUserRoles", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "EmailIndex", + table: "AspNetUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "UserNameIndex", + table: "AspNetUsers", + column: "NormalizedUserName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Notepad_InquiryId", + table: "Notepad", + column: "InquiryId"); + + migrationBuilder.CreateIndex( + name: "IX_Notepad_UserId", + table: "Notepad", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Paragraph_LessonId", + table: "Paragraph", + column: "LessonId"); + + migrationBuilder.CreateIndex( + name: "IX_Success_UserId", + table: "Success", + column: "UserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AspNetRoleClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserClaims"); + + migrationBuilder.DropTable( + name: "AspNetUserLogins"); + + migrationBuilder.DropTable( + name: "AspNetUserRoles"); + + migrationBuilder.DropTable( + name: "AspNetUserTokens"); + + migrationBuilder.DropTable( + name: "BlackList"); + + migrationBuilder.DropTable( + name: "InquiryTable"); + + migrationBuilder.DropTable( + name: "Notepad"); + + migrationBuilder.DropTable( + name: "Paragraph"); + + migrationBuilder.DropTable( + name: "Solution"); + + migrationBuilder.DropTable( + name: "Success"); + + migrationBuilder.DropTable( + name: "AspNetRoles"); + + migrationBuilder.DropTable( + name: "AspNetUsers"); + + migrationBuilder.DropTable( + name: "Lesson"); + + migrationBuilder.DropTable( + name: "Inquiries"); + + migrationBuilder.DropTable( + name: "User"); + + migrationBuilder.DropSequence( + name: "ContentLessonEntitySequence"); + } + } +} diff --git a/API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs b/API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs new file mode 100644 index 0000000..50a98ac --- /dev/null +++ b/API_SQLuedo/DbContextLib/Migrations/UserDbContextModelSnapshot.cs @@ -0,0 +1,592 @@ +// +using System; +using DbContextLib; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DbContextLib.Migrations +{ + [DbContext(typeof(UserDbContext))] + partial class UserDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.HasSequence("ContentLessonEntitySequence"); + + modelBuilder.Entity("Entities.BlackListEntity", b => + { + b.Property("Email") + .HasColumnType("text"); + + b.Property("ExpirationDate") + .HasColumnType("date"); + + b.HasKey("Email"); + + b.ToTable("BlackList"); + }); + + modelBuilder.Entity("Entities.ContentLessonEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValueSql("nextval('\"ContentLessonEntitySequence\"')"); + + NpgsqlPropertyBuilderExtensions.UseSequence(b.Property("Id")); + + b.Property("ContentContent") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContentTitle") + .IsRequired() + .HasColumnType("text"); + + b.Property("LessonId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("LessonId"); + + b.ToTable((string)null); + + b.UseTpcMappingStrategy(); + }); + + modelBuilder.Entity("Entities.InquiryEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsUser") + .HasColumnType("boolean"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Inquiries"); + }); + + modelBuilder.Entity("Entities.InquiryTableEntity", b => + { + b.Property("OwnerId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + b.Property("ConnectionInfo") + .IsRequired() + .HasColumnType("text"); + + b.Property("DatabaseName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("OwnerId"); + + b.ToTable("InquiryTable"); + }); + + modelBuilder.Entity("Entities.LessonEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("LastEdit") + .HasColumnType("date"); + + b.Property("LastPublisher") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Lesson"); + }); + + modelBuilder.Entity("Entities.NotepadEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("InquiryId") + .HasColumnType("integer"); + + b.Property("Notes") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InquiryId"); + + b.HasIndex("UserId"); + + b.ToTable("Notepad"); + }); + + modelBuilder.Entity("Entities.SolutionEntity", b => + { + b.Property("OwnerId") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + b.Property("Explaination") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurderPlace") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurderWeapon") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurdererFirstName") + .IsRequired() + .HasColumnType("text"); + + b.Property("MurdererLastName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("OwnerId"); + + b.ToTable("Solution"); + }); + + modelBuilder.Entity("Entities.SuccessEntity", b => + { + b.Property("InquiryId") + .HasColumnType("integer"); + + b.Property("IsFinished") + .HasColumnType("boolean"); + + b.Property("UserId") + .HasColumnType("integer"); + + b.HasKey("InquiryId"); + + b.HasIndex("UserId"); + + b.ToTable("Success"); + }); + + modelBuilder.Entity("Entities.UserEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsAdmin") + .HasColumnType("boolean"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Username") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Entities.ParagraphEntity", b => + { + b.HasBaseType("Entities.ContentLessonEntity"); + + b.Property("Comment") + .IsRequired() + .HasColumnType("text"); + + b.Property("Content") + .IsRequired() + .HasColumnType("text"); + + b.Property("Info") + .IsRequired() + .HasColumnType("text"); + + b.Property("Query") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.ToTable("Paragraph"); + }); + + modelBuilder.Entity("Entities.ContentLessonEntity", b => + { + b.HasOne("Entities.LessonEntity", "Lesson") + .WithMany("Content") + .HasForeignKey("LessonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lesson"); + }); + + modelBuilder.Entity("Entities.InquiryTableEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Entities.NotepadEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Inquiry") + .WithMany() + .HasForeignKey("InquiryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.UserEntity", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Inquiry"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Entities.SolutionEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Entities.SuccessEntity", b => + { + b.HasOne("Entities.InquiryEntity", "Inquiry") + .WithMany() + .HasForeignKey("InquiryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entities.UserEntity", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Inquiry"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entities.LessonEntity", b => + { + b.Navigation("Content"); + }); +#pragma warning restore 612, 618 + } + } +} From 6843d969e515b4414fc0a62fa51dfde0135add02 Mon Sep 17 00:00:00 2001 From: Nestisse Date: Wed, 3 Apr 2024 09:14:25 +0200 Subject: [PATCH 78/78] Suppression du authorize pour test --- API_SQLuedo/API/Controllers/UserController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/API_SQLuedo/API/Controllers/UserController.cs b/API_SQLuedo/API/Controllers/UserController.cs index e80e096..3dfad39 100644 --- a/API_SQLuedo/API/Controllers/UserController.cs +++ b/API_SQLuedo/API/Controllers/UserController.cs @@ -8,7 +8,6 @@ using Model.OrderCriteria; namespace API.Controllers; [Route("api/v{version:apiVersion}/[controller]")] -[Authorize] [ApiVersion("1.0")] [ApiController] public class UsersController(ILogger logger, IUserService userService) : ControllerBase