This commit is contained in:
Tizian.Breuch
2025-08-01 15:21:40 +02:00
parent 4dfc50d572
commit 1317844ce5
19 changed files with 66 additions and 147 deletions

View File

@@ -9,37 +9,37 @@ using Webshop.Infrastructure.Data;
namespace Webshop.Infrastructure.Repositories
{
public class categorieRepository : IcategorieRepository
public class CategorieRepository : ICategorieRepository
{
private readonly ApplicationDbContext _context;
public categorieRepository(ApplicationDbContext context)
public CategorieRepository(ApplicationDbContext context)
{
_context = context;
}
public async Task<IEnumerable<categorie>> GetAllAsync()
public async Task<IEnumerable<Categorie>> GetAllAsync()
{
return await _context.categories.ToListAsync();
}
public async Task<categorie?> GetByIdAsync(Guid id)
public async Task<Categorie?> GetByIdAsync(Guid id)
{
return await _context.categories.FindAsync(id);
}
public async Task<categorie?> GetBySlugAsync(string slug)
public async Task<Categorie?> GetBySlugAsync(string slug)
{
return await _context.categories.FirstOrDefaultAsync(c => c.Slug == slug);
}
public async Task AddAsync(categorie categorie)
public async Task AddAsync(Categorie categorie)
{
_context.categories.Add(categorie);
await _context.SaveChangesAsync();
}
public async Task UpdateAsync(categorie categorie)
public async Task UpdateAsync(Categorie categorie)
{
_context.categories.Update(categorie);
await _context.SaveChangesAsync();