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

@@ -14,7 +14,7 @@ namespace Webshop.Infrastructure.Data
public DbSet<Product> Products { get; set; } = default!;
public DbSet<ProductVariant> ProductVariants { get; set; } = default!;
public DbSet<categorie> categories { get; set; } = default!;
public DbSet<Categorie> categories { get; set; } = default!;
public DbSet<Customer> Customers { get; set; } = default!;
public DbSet<Address> Addresses { get; set; } = default!;
public DbSet<Order> Orders { get; set; } = default!;
@@ -28,7 +28,7 @@ namespace Webshop.Infrastructure.Data
public DbSet<Productcategorie> Productcategories { get; set; } = default!;
public DbSet<ProductDiscount> ProductDiscounts { get; set; } = default!;
public DbSet<categorieDiscount> categorieDiscounts { get; set; } = default!;
public DbSet<CategorieDiscount> categorieDiscounts { get; set; } = default!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
@@ -47,11 +47,11 @@ namespace Webshop.Infrastructure.Data
modelBuilder.Entity<Productcategorie>().HasKey(pc => new { pc.ProductId, pc.categorieId });
modelBuilder.Entity<ProductDiscount>().HasKey(pd => new { pd.ProductId, pd.DiscountId });
modelBuilder.Entity<categorieDiscount>().HasKey(cd => new { cd.categorieId, cd.DiscountId });
modelBuilder.Entity<CategorieDiscount>().HasKey(cd => new { cd.categorieId, cd.DiscountId });
modelBuilder.Entity<Product>().HasIndex(p => p.SKU).IsUnique();
modelBuilder.Entity<Product>().HasIndex(p => p.Slug).IsUnique();
modelBuilder.Entity<categorie>().HasIndex(c => c.Slug).IsUnique();
modelBuilder.Entity<Categorie>().HasIndex(c => c.Slug).IsUnique();
modelBuilder.Entity<Discount>().HasIndex(d => d.CouponCode).IsUnique().HasFilter("\"CouponCode\" IS NOT NULL");
modelBuilder.Entity<Setting>().HasIndex(s => s.Key).IsUnique();
modelBuilder.Entity<Order>().HasIndex(o => o.OrderNumber).IsUnique();
@@ -99,7 +99,7 @@ namespace Webshop.Infrastructure.Data
modelBuilder.Entity<PaymentMethod>()
.Property(pm => pm.ProcessingFee).HasPrecision(18, 2);
modelBuilder.Entity<categorie>()
modelBuilder.Entity<Categorie>()
.HasOne(c => c.Parentcategorie)
.WithMany(c => c.Subcategories)
.HasForeignKey(c => c.ParentcategorieId)

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();