This commit is contained in:
Tizian.Breuch
2025-07-31 16:37:35 +02:00
parent 2d93fda7e9
commit 3858375b66
9 changed files with 290 additions and 3349 deletions

View File

@@ -1,11 +1,11 @@
// Auto-generiert von CreateWebshopFiles.ps1
// src/Webshop.Infrastructure/Repositories/ShippingMethodRepository.cs
using Microsoft.EntityFrameworkCore;
using Webshop.Domain.Entities;
using Webshop.Domain.Interfaces;
using Webshop.Infrastructure.Data;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Webshop.Domain.Entities;
using Webshop.Domain.Interfaces;
using Webshop.Infrastructure.Data;
namespace Webshop.Infrastructure.Repositories
{
@@ -18,12 +18,15 @@ namespace Webshop.Infrastructure.Repositories
_context = context;
}
// Fügen Sie hier Repository-Methoden hinzu
// Beispiel:
// public async Task<IEnumerable<T>> GetAllAsync() { return await _context.Set<T>().ToListAsync(); }
// public async Task<T?> GetByIdAsync(Guid id) { return await _context.Set<T>().FindAsync(id); }
// public async Task AddAsync(T entity) { _context.Set<T>().Add(entity); await _context.SaveChangesAsync(); }
// public async Task UpdateAsync(T entity) { _context.Set<T>().Update(entity); await _context.SaveChangesAsync(); }
// public async Task DeleteAsync(Guid id) { var entity = await _context.Set<T>().FindAsync(id); if (entity != null) { _context.Set<T>().Remove(entity); await _context.SaveChangesAsync(); } }
public async Task<IEnumerable<ShippingMethod>> GetAllAsync() => await _context.ShippingMethods.ToListAsync();
public async Task<ShippingMethod?> GetByIdAsync(Guid id) // << HINZUFÜGEN >>
{
return await _context.ShippingMethods.FindAsync(id);
}
public async Task AddAsync(ShippingMethod shippingMethod) { _context.ShippingMethods.Add(shippingMethod); await _context.SaveChangesAsync(); }
public async Task UpdateAsync(ShippingMethod shippingMethod) { _context.ShippingMethods.Update(shippingMethod); await _context.SaveChangesAsync(); }
public async Task DeleteAsync(Guid id) { var entity = await _context.ShippingMethods.FindAsync(id); if (entity != null) { _context.ShippingMethods.Remove(entity); await _context.SaveChangesAsync(); } }
}
}
}