slug fix
This commit is contained in:
@@ -17,5 +17,6 @@ namespace Webshop.Application.DTOs.Products
|
||||
public bool IsInStock { get; set; }
|
||||
public int StockQuantity { get; set; }
|
||||
public string? ImageUrl { get; set; }
|
||||
public string Slug { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
// Auto-generiert von CreateWebshopFiles.ps1
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Domain.Interfaces;
|
||||
using Webshop.Domain.Entities;
|
||||
using Webshop.Application.DTOs.Products;
|
||||
using Webshop.Application.Services.Public.Interfaces;
|
||||
|
||||
using Webshop.Domain.Interfaces;
|
||||
|
||||
namespace Webshop.Application.Services.Public
|
||||
{
|
||||
@@ -19,9 +16,47 @@ namespace Webshop.Application.Services.Public
|
||||
_productRepository = productRepository;
|
||||
}
|
||||
|
||||
// HIER KOMMT DER VORHERIGE PRODUCTSERVICE CODE HIN (GetAllProductsAsync, CreateProductAsync etc.)
|
||||
// Hier sind Platzhalter-Implementierungen, die Sie durch den vollständigen Code ersetzen müssen:
|
||||
public async Task<IEnumerable<ProductDto>> GetAllProductsAsync() { return new List<ProductDto>(); }
|
||||
public async Task<ProductDto> CreateProductAsync(ProductDto productDto) { return null; }
|
||||
// Wir verwenden jetzt den von Ihnen vorgegebenen Namen
|
||||
public async Task<IEnumerable<ProductDto>> GetAllProductsAsync()
|
||||
{
|
||||
var products = await _productRepository.GetAllProductsAsync();
|
||||
|
||||
return products
|
||||
.Where(p => p.IsActive) // Nur aktive Produkte anzeigen
|
||||
.Select(p => new ProductDto
|
||||
{
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
Description = p.ShortDescription,
|
||||
Price = p.Price,
|
||||
SKU = p.SKU,
|
||||
ImageUrl = p.ImageUrl,
|
||||
IsInStock = p.IsInStock,
|
||||
Slug = p.Slug // Mapping für Slug
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
// Diese Methode wird hinzugefügt, um das Interface zu erfüllen
|
||||
public async Task<ProductDto?> GetProductBySlugAsync(string slug)
|
||||
{
|
||||
var product = await _productRepository.GetBySlugAsync(slug);
|
||||
|
||||
if (product == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ProductDto
|
||||
{
|
||||
Id = product.Id,
|
||||
Name = product.Name,
|
||||
Description = product.Description,
|
||||
Price = product.Price,
|
||||
SKU = product.SKU,
|
||||
ImageUrl = product.ImageUrl,
|
||||
IsInStock = product.IsInStock,
|
||||
Slug = product.Slug // Mapping für Slug
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user