Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
c45310e81a |
1
.vscode/bash.md
vendored
1
.vscode/bash.md
vendored
@ -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
|
||||
```
|
||||
|
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -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"
|
||||
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -22,6 +22,10 @@
|
||||
"dev": {
|
||||
"host": "http://localhost:5243",
|
||||
"token": "ey..dev"
|
||||
},
|
||||
"media": {
|
||||
"host": "https://products.affirm.duckdns.org/",
|
||||
"token": "ey..media"
|
||||
}
|
||||
}
|
||||
}
|
18
Dockerfile
18
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
|
||||
|
@ -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:
|
||||
# volumes:
|
||||
# postgres_data:
|
||||
|
||||
# version: "3"
|
||||
# services:
|
||||
# one-review-webapp:
|
||||
# image: one-review-webapp
|
||||
# ports:
|
||||
# - 5001:5001
|
||||
# networks: {}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"rollForward": "latestMinor",
|
||||
"version": "8.0.100"
|
||||
"version": "9.0.100"
|
||||
}
|
||||
}
|
@ -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<Product> 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<Product> products) =>
|
||||
products.Select(FromDomain).ToArray();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
@ -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<Product> _ProductsRepository = [];
|
||||
// private static readonly List<User> _UsersRepository = [];
|
||||
|
||||
public ReadOnlyCollection<Product> Get() =>
|
||||
_ProductsRepository.AsReadOnly();
|
||||
|
||||
// 1. fetch user
|
||||
// 1. fetch product
|
||||
// 1. check wether the user reached the
|
||||
|
Loading…
x
Reference in New Issue
Block a user