Projektdateien hinzufügen.
This commit is contained in:
32
Webshop.Application/Services/ProductService.cs
Normal file
32
Webshop.Application/Services/ProductService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
// src/Webshop.Application/Services/ProductService.cs
|
||||
using Webshop.Application.DTOs;
|
||||
using Webshop.Domain.Interfaces;
|
||||
|
||||
namespace Webshop.Application.Services
|
||||
{
|
||||
public class ProductService
|
||||
{
|
||||
private readonly IProductRepository _productRepository;
|
||||
|
||||
public ProductService(IProductRepository productRepository)
|
||||
{
|
||||
_productRepository = productRepository;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ProductDto>> GetAllProductsAsync()
|
||||
{
|
||||
var productsFromDb = await _productRepository.GetAllProductsAsync();
|
||||
|
||||
var productDtos = productsFromDb.Select(p => new ProductDto
|
||||
{
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
Description = p.Description,
|
||||
Price = p.Price,
|
||||
Sku = p.SKU
|
||||
});
|
||||
|
||||
return productDtos;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user