Projektdateien hinzufügen.
This commit is contained in:
7
Webshop.Application/Class1.cs
Normal file
7
Webshop.Application/Class1.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace Webshop.Application
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
12
Webshop.Application/DTOs/ProductDto.cs
Normal file
12
Webshop.Application/DTOs/ProductDto.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
// src/Webshop.Application/DTOs/ProductDto.cs
|
||||
namespace Webshop.Application.DTOs
|
||||
{
|
||||
public class ProductDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public decimal Price { get; set; }
|
||||
public string Sku { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Webshop.Application/Webshop.Application.csproj
Normal file
17
Webshop.Application/Webshop.Application.csproj
Normal file
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Webshop.Domain\Webshop.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user