test bilder upload
Some checks failed
Branch - test - Build and Push Backend API Docker Image / build-and-push (push) Failing after 20s

This commit is contained in:
Tizian.Breuch
2025-11-07 09:49:51 +01:00
parent c078526800
commit 7aa5ec9500
4 changed files with 164 additions and 48 deletions

View File

@@ -1,3 +1,4 @@
// src/Webshop.Infrastructure/Repositories/ProductRepository.cs
using Microsoft.EntityFrameworkCore;
using Webshop.Domain.Entities;
using Webshop.Domain.Interfaces;
@@ -8,7 +9,7 @@ using System.Threading.Tasks;
namespace Webshop.Infrastructure.Repositories
{
public class ProductRepository : IProductRepository
public class ProductRepository : IProductRepository // Implementiert das korrigierte Interface
{
private readonly ApplicationDbContext _context;
@@ -27,22 +28,29 @@ namespace Webshop.Infrastructure.Repositories
return await _context.Products.FindAsync(id);
}
// --- HIER DIE NEUE METHODE IMPLEMENTIEREN ---
public async Task<Product?> GetBySlugAsync(string slug)
{
// Sucht nur nach aktiven Produkten, was für die öffentliche Ansicht korrekt ist.
return await _context.Products.FirstOrDefaultAsync(p => p.Slug == slug && p.IsActive);
}
// --- NEUE METHODE ---
public async Task<Product?> GetProductByIdForUpdateAsync(Guid id)
{
return await _context.Products
.Include(p => p.Images)
.Include(p => p.Productcategories)
.FirstOrDefaultAsync(p => p.Id == id);
}
public async Task AddProductAsync(Product product)
{
await _context.Products.AddAsync(product);
await _context.SaveChangesAsync();
}
public async Task UpdateProductAsync(Product product)
// --- KORRIGIERTE UPDATE-METHODE (OHNE PARAMETER) ---
public async Task UpdateProductAsync()
{
//_context.Products.Update(product);
await _context.SaveChangesAsync();
}