test bilder upload
Some checks failed
Branch - test - Build and Push Backend API Docker Image / build-and-push (push) Failing after 20s
Some checks failed
Branch - test - Build and Push Backend API Docker Image / build-and-push (push) Failing after 20s
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user