Compare commits

...

1 Commits
main ... net9

Author SHA1 Message Date
c45310e81a Bump
Get without id
Comment out db
docker.io
2024-11-17 12:22:43 -07:00
9 changed files with 57 additions and 29 deletions

1
.vscode/bash.md vendored
View File

@ -14,4 +14,5 @@ dotnet run --project src/OneReview
```bash 1731643960696 = 638672407606960000 = Thu Nov 14 2024 21:12:40 GMT-0700 (Mountain Standard Time) ```bash 1731643960696 = 638672407606960000 = Thu Nov 14 2024 21:12:40 GMT-0700 (Mountain Standard Time)
docker compose up --build docker compose up --build
podman compose up --build
``` ```

2
.vscode/launch.json vendored
View File

@ -9,7 +9,7 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "build", "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": [ "args": [
"s", "s",
"test" "test"

View File

@ -22,6 +22,10 @@
"dev": { "dev": {
"host": "http://localhost:5243", "host": "http://localhost:5243",
"token": "ey..dev" "token": "ey..dev"
},
"media": {
"host": "https://products.affirm.duckdns.org/",
"token": "ey..media"
} }
} }
} }

View File

@ -1,28 +1,28 @@
# Stage 1: Build Stage # 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 WORKDIR /src
# restore # restore
COPY ["src/Sprint-Console/Sprint-Console.csproj", "Sprint-Console/"] COPY ["src/OneReview/OneReview.csproj", "OneReview/"]
RUN dotnet restore 'Sprint-Console/Sprint-Console.csproj' RUN dotnet restore 'OneReview/OneReview.csproj'
# build # build
COPY ["src/Sprint-Console", "Sprint-Console/"] COPY ["src/OneReview", "OneReview/"]
WORKDIR /src/Sprint-Console WORKDIR /src/OneReview
RUN dotnet build 'Sprint-Console.csproj' -c Release -o /app/build RUN dotnet build 'OneReview.csproj' -c Release -o /app/build
# Stage 2: Publish Stage # Stage 2: Publish Stage
FROM build AS publish 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 # 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 ENV ASPNETCORE_HTTP_PORTS=5001
EXPOSE 5001 EXPOSE 5001
WORKDIR /app WORKDIR /app
COPY --from=publish /app/publish . COPY --from=publish /app/publish .
ENTRYPOINT [ "dotnet", "Sprint-Console.dll" ] ENTRYPOINT [ "dotnet", "OneReview.dll" ]
# docker build -t sprint-console-001 . # docker build -t sprint-console-001 .
# docker images ls | grep -i 001 # docker images ls | grep -i 001

View File

@ -1,5 +1,3 @@
version: "3.9"
services: services:
webapp: webapp:
container_name: one-review-api container_name: one-review-api
@ -7,21 +5,29 @@ services:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "5024:5043" - "5005:5001"
environment: environment:
- ASPNETCORE_ENVIRONMENT=Devlopment - ASPNETCORE_ENVIRONMENT=Production
db: # db:
container_name: one-review-db # container_name: one-review-db
image: postgres:latest # image: docker.io/postgres:latest
ports: # ports:
- "5432:5432" # - "5432:5432"
environment: # environment:
POSTGRES_DB: onereview # POSTGRES_DB: onereview
POSTGRES_USER: postgres # POSTGRES_USER: postgres
POSTGRES_PASSWORD: strong_password # POSTGRES_PASSWORD: strong_password
volumes: # volumes:
- postgres_data:/var/lib/postgresql/data # - postgres_data:/var/lib/postgresql/data
volumes: # volumes:
postgres_data: # postgres_data:
# version: "3"
# services:
# one-review-webapp:
# image: one-review-webapp
# ports:
# - 5001:5001
# networks: {}

View File

@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"rollForward": "latestMinor", "rollForward": "latestMinor",
"version": "8.0.100" "version": "9.0.100"
} }
} }

View File

@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OneReview.Domain; using OneReview.Domain;
using OneReview.Services; using OneReview.Services;
using System.Collections;
using System.Collections.ObjectModel;
namespace OneReview.Controllers; namespace OneReview.Controllers;
@ -11,6 +13,14 @@ public class ProductsController(ProductService productService) : ControllerBase
private readonly ProductService _ProductService = productService; private readonly ProductService _ProductService = productService;
[HttpGet()]
public IActionResult Get()
{
ReadOnlyCollection<Product> products = _ProductService.Get();
ProductResponse?[] productResponses = ProductResponse.FromDomain(products);
return Ok(productResponses);
}
[HttpPost] [HttpPost]
public IActionResult Create(CreateProductRequest request) public IActionResult Create(CreateProductRequest request)
{ {
@ -75,6 +85,9 @@ public class ProductsController(ProductService productService) : ControllerBase
Category: product.Category, Category: product.Category,
SubCategory: product.SubCategory); SubCategory: product.SubCategory);
public static ProductResponse?[] FromDomain(IEnumerable<Product> products) =>
products.Select(FromDomain).ToArray();
} }
} }

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>

View File

@ -1,4 +1,5 @@
using OneReview.Domain; using OneReview.Domain;
using System.Collections.ObjectModel;
namespace OneReview.Services; namespace OneReview.Services;
@ -8,6 +9,9 @@ public class ProductService
private static readonly List<Product> _ProductsRepository = []; private static readonly List<Product> _ProductsRepository = [];
// private static readonly List<User> _UsersRepository = []; // private static readonly List<User> _UsersRepository = [];
public ReadOnlyCollection<Product> Get() =>
_ProductsRepository.AsReadOnly();
// 1. fetch user // 1. fetch user
// 1. fetch product // 1. fetch product
// 1. check wether the user reached the // 1. check wether the user reached the