This commit is contained in:
Tizian.Breuch
2025-07-23 21:08:30 +02:00
parent d20a6d6ae6
commit ce69373adb
85 changed files with 2311 additions and 332 deletions

View File

@@ -1,12 +1,16 @@
// src/Webshop.Infrastructure/Repositories/SupplierRepository.cs
using Microsoft.EntityFrameworkCore; // Für ToListAsync
// src/Webshop.Infrastructure/Repositories/SupplierRepository.cs
// Auto-generiert von CreateWebshopFiles.ps1 (aktualisiert um Implementierungen)
using Microsoft.EntityFrameworkCore; // Wichtig für ToListAsync, FindAsync etc.
using Webshop.Domain.Entities;
using Webshop.Domain.Interfaces;
using Webshop.Infrastructure.Data;
using System; // Für Guid
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Webshop.Infrastructure.Repositories
{
public class SupplierRepository : ISupplierRepository
public class SupplierRepository : ISupplierRepository // Hier muss das Interface stehen
{
private readonly ApplicationDbContext _context;
@@ -15,6 +19,8 @@ namespace Webshop.Infrastructure.Repositories
_context = context;
}
// --- IMPLEMENTIERUNG DER ISupplierRepository METHODEN ---
public async Task<IEnumerable<Supplier>> GetAllSuppliersAsync()
{
return await _context.Suppliers.ToListAsync();
@@ -28,7 +34,7 @@ namespace Webshop.Infrastructure.Repositories
public async Task AddSupplierAsync(Supplier supplier)
{
_context.Suppliers.Add(supplier);
await _context.SaveChangesAsync();
await _context.SaveChangesAsync(); // Änderungen in der DB speichern
}
public async Task UpdateSupplierAsync(Supplier supplier)
@@ -39,11 +45,11 @@ namespace Webshop.Infrastructure.Repositories
public async Task DeleteSupplierAsync(Guid id)
{
var supplier = await _context.Suppliers.FindAsync(id);
var supplier = await _context.Suppliers.FindAsync(id); // Lieferant zuerst finden
if (supplier != null)
{
_context.Suppliers.Remove(supplier);
await _context.SaveChangesAsync();
_context.Suppliers.Remove(supplier); // Lieferant entfernen
await _context.SaveChangesAsync(); // Änderungen speichern
}
}
}