diff --git a/.vscode/bash.md b/.vscode/bash.md index b10318d..2d1325c 100644 --- a/.vscode/bash.md +++ b/.vscode/bash.md @@ -14,4 +14,5 @@ dotnet run --project src/OneReview ```bash 1731643960696 = 638672407606960000 = Thu Nov 14 2024 21:12:40 GMT-0700 (Mountain Standard Time) docker compose up --build +podman compose up --build ``` diff --git a/.vscode/launch.json b/.vscode/launch.json index 2ddf60a..10cd1e9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/src/OneReview/bin/Debug/net8.0/win-x64/OneReview.dll", + "program": "${workspaceFolder}/src/OneReview/bin/Debug/net9.0/win-x64/OneReview.dll", "args": [ "s", "test" diff --git a/.vscode/settings.json b/.vscode/settings.json index e4a8665..02f49a3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,6 +22,10 @@ "dev": { "host": "http://localhost:5243", "token": "ey..dev" + }, + "media": { + "host": "https://products.affirm.duckdns.org/", + "token": "ey..media" } } } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c519841..b0f7ae7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,28 @@ # Stage 1: Build Stage -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS Build +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /src # restore -COPY ["src/Sprint-Console/Sprint-Console.csproj", "Sprint-Console/"] -RUN dotnet restore 'Sprint-Console/Sprint-Console.csproj' +COPY ["src/OneReview/OneReview.csproj", "OneReview/"] +RUN dotnet restore 'OneReview/OneReview.csproj' # build -COPY ["src/Sprint-Console", "Sprint-Console/"] -WORKDIR /src/Sprint-Console -RUN dotnet build 'Sprint-Console.csproj' -c Release -o /app/build +COPY ["src/OneReview", "OneReview/"] +WORKDIR /src/OneReview +RUN dotnet build 'OneReview.csproj' -c Release -o /app/build # Stage 2: Publish Stage FROM build AS publish -RUN dotnet publish 'Sprint-Console.csproj' -c Release -o /app/publish +RUN dotnet publish 'OneReview.csproj' -c Release -o /app/publish # Stage 3: Run Stage -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:9.0 ENV ASPNETCORE_HTTP_PORTS=5001 EXPOSE 5001 WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT [ "dotnet", "Sprint-Console.dll" ] +ENTRYPOINT [ "dotnet", "OneReview.dll" ] # docker build -t sprint-console-001 . # docker images ls | grep -i 001 diff --git a/docker-compose.yaml b/docker-compose.yaml index 6cff5cf..66d9a9d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,5 +1,3 @@ -version: "3.9" - services: webapp: container_name: one-review-api @@ -7,21 +5,29 @@ services: context: . dockerfile: Dockerfile ports: - - "5024:5043" + - "5005:5001" environment: - - ASPNETCORE_ENVIRONMENT=Devlopment + - ASPNETCORE_ENVIRONMENT=Production - db: - container_name: one-review-db - image: postgres:latest - ports: - - "5432:5432" - environment: - POSTGRES_DB: onereview - POSTGRES_USER: postgres - POSTGRES_PASSWORD: strong_password - volumes: - - postgres_data:/var/lib/postgresql/data + # db: + # container_name: one-review-db + # image: docker.io/postgres:latest + # ports: + # - "5432:5432" + # environment: + # POSTGRES_DB: onereview + # POSTGRES_USER: postgres + # POSTGRES_PASSWORD: strong_password + # volumes: + # - postgres_data:/var/lib/postgresql/data -volumes: - postgres_data: \ No newline at end of file +# volumes: +# postgres_data: + +# version: "3" +# services: +# one-review-webapp: +# image: one-review-webapp +# ports: +# - 5001:5001 +# networks: {} \ No newline at end of file diff --git a/global.json b/global.json index 744a6ea..3d8048a 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { "rollForward": "latestMinor", - "version": "8.0.100" + "version": "9.0.100" } } \ No newline at end of file diff --git a/src/OneReview/Controllers/ProductsController.cs b/src/OneReview/Controllers/ProductsController.cs index 49785cc..d35d5bd 100644 --- a/src/OneReview/Controllers/ProductsController.cs +++ b/src/OneReview/Controllers/ProductsController.cs @@ -1,6 +1,8 @@ using Microsoft.AspNetCore.Mvc; using OneReview.Domain; using OneReview.Services; +using System.Collections; +using System.Collections.ObjectModel; namespace OneReview.Controllers; @@ -11,6 +13,14 @@ public class ProductsController(ProductService productService) : ControllerBase private readonly ProductService _ProductService = productService; + [HttpGet()] + public IActionResult Get() + { + ReadOnlyCollection products = _ProductService.Get(); + ProductResponse?[] productResponses = ProductResponse.FromDomain(products); + return Ok(productResponses); + } + [HttpPost] public IActionResult Create(CreateProductRequest request) { @@ -75,6 +85,9 @@ public class ProductsController(ProductService productService) : ControllerBase Category: product.Category, SubCategory: product.SubCategory); + public static ProductResponse?[] FromDomain(IEnumerable products) => + products.Select(FromDomain).ToArray(); + } } \ No newline at end of file diff --git a/src/OneReview/OneReview.csproj b/src/OneReview/OneReview.csproj index 78cb917..b5ddf6f 100644 --- a/src/OneReview/OneReview.csproj +++ b/src/OneReview/OneReview.csproj @@ -1,6 +1,6 @@ - net8.0 + net9.0 enable enable diff --git a/src/OneReview/Services/ProductService.cs b/src/OneReview/Services/ProductService.cs index 9f1c1df..ac567d8 100644 --- a/src/OneReview/Services/ProductService.cs +++ b/src/OneReview/Services/ProductService.cs @@ -1,4 +1,5 @@ using OneReview.Domain; +using System.Collections.ObjectModel; namespace OneReview.Services; @@ -8,6 +9,9 @@ public class ProductService private static readonly List _ProductsRepository = []; // private static readonly List _UsersRepository = []; + public ReadOnlyCollection Get() => + _ProductsRepository.AsReadOnly(); + // 1. fetch user // 1. fetch product // 1. check wether the user reached the