Bump
Get without id Comment out db docker.io
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user