This commit is contained in:
Tizian.Breuch
2025-08-01 15:11:42 +02:00
parent 96f082b38f
commit 55eeaca7f4
29 changed files with 452 additions and 452 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<Category> categorys { 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!;
@@ -26,9 +26,9 @@ namespace Webshop.Infrastructure.Data
public DbSet<PaymentMethod> PaymentMethods { get; set; } = default!;
public DbSet<Setting> Settings { get; set; } = default!;
public DbSet<ProductCategory> Productcategorys { get; set; } = default!;
public DbSet<Productcategorie> Productcategories { get; set; } = default!;
public DbSet<ProductDiscount> ProductDiscounts { get; set; } = default!;
public DbSet<CategoryDiscount> CategoryDiscounts { get; set; } = default!;
public DbSet<categorieDiscount> categorieDiscounts { get; set; } = default!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
@@ -45,13 +45,13 @@ namespace Webshop.Infrastructure.Data
}
}
modelBuilder.Entity<ProductCategory>().HasKey(pc => new { pc.ProductId, pc.CategoryId });
modelBuilder.Entity<Productcategorie>().HasKey(pc => new { pc.ProductId, pc.categorieId });
modelBuilder.Entity<ProductDiscount>().HasKey(pd => new { pd.ProductId, pd.DiscountId });
modelBuilder.Entity<CategoryDiscount>().HasKey(cd => new { cd.CategoryId, 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<Category>().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,10 +99,10 @@ namespace Webshop.Infrastructure.Data
modelBuilder.Entity<PaymentMethod>()
.Property(pm => pm.ProcessingFee).HasPrecision(18, 2);
modelBuilder.Entity<Category>()
.HasOne(c => c.ParentCategory)
.WithMany(c => c.Subcategorys)
.HasForeignKey(c => c.ParentCategoryId)
modelBuilder.Entity<categorie>()
.HasOne(c => c.Parentcategorie)
.WithMany(c => c.Subcategories)
.HasForeignKey(c => c.ParentcategorieId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<OrderItem>()

View File

@@ -218,7 +218,7 @@ namespace Webshop.Infrastructure.Migrations
b.ToTable("Addresses");
});
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -249,7 +249,7 @@ namespace Webshop.Infrastructure.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<Guid?>("ParentCategoryId")
b.Property<Guid?>("ParentcategorieId")
.HasColumnType("uuid");
b.Property<string>("Slug")
@@ -259,27 +259,27 @@ namespace Webshop.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("ParentCategoryId");
b.HasIndex("ParentcategorieId");
b.HasIndex("Slug")
.IsUnique();
b.ToTable("categorys");
b.ToTable("categories");
});
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
modelBuilder.Entity("Webshop.Domain.Entities.categorieDiscount", b =>
{
b.Property<Guid>("CategoryId")
b.Property<Guid>("categorieId")
.HasColumnType("uuid");
b.Property<Guid>("DiscountId")
.HasColumnType("uuid");
b.HasKey("CategoryId", "DiscountId");
b.HasKey("categorieId", "DiscountId");
b.HasIndex("DiscountId");
b.ToTable("CategoryDiscounts");
b.ToTable("categorieDiscounts");
});
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
@@ -655,19 +655,19 @@ namespace Webshop.Infrastructure.Migrations
b.ToTable("Products");
});
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
modelBuilder.Entity("Webshop.Domain.Entities.Productcategorie", b =>
{
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("CategoryId")
b.Property<Guid>("categorieId")
.HasColumnType("uuid");
b.HasKey("ProductId", "CategoryId");
b.HasKey("ProductId", "categorieId");
b.HasIndex("CategoryId");
b.HasIndex("categorieId");
b.ToTable("Productcategorys");
b.ToTable("Productcategories");
});
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
@@ -1006,31 +1006,31 @@ namespace Webshop.Infrastructure.Migrations
b.Navigation("Customer");
});
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
{
b.HasOne("Webshop.Domain.Entities.Category", "ParentCategory")
.WithMany("Subcategorys")
.HasForeignKey("ParentCategoryId")
b.HasOne("Webshop.Domain.Entities.categorie", "Parentcategorie")
.WithMany("Subcategories")
.HasForeignKey("ParentcategorieId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("ParentCategory");
b.Navigation("Parentcategorie");
});
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
modelBuilder.Entity("Webshop.Domain.Entities.categorieDiscount", b =>
{
b.HasOne("Webshop.Domain.Entities.Category", "Category")
.WithMany("CategoryDiscounts")
.HasForeignKey("CategoryId")
b.HasOne("Webshop.Domain.Entities.categorie", "categorie")
.WithMany("categorieDiscounts")
.HasForeignKey("categorieId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Webshop.Domain.Entities.Discount", "Discount")
.WithMany("CategoryDiscounts")
.WithMany("categorieDiscounts")
.HasForeignKey("DiscountId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Category");
b.Navigation("categorie");
b.Navigation("Discount");
});
@@ -1117,21 +1117,21 @@ namespace Webshop.Infrastructure.Migrations
b.Navigation("Supplier");
});
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
modelBuilder.Entity("Webshop.Domain.Entities.Productcategorie", b =>
{
b.HasOne("Webshop.Domain.Entities.Category", "Category")
.WithMany("Productcategorys")
.HasForeignKey("CategoryId")
b.HasOne("Webshop.Domain.Entities.categorie", "categorie")
.WithMany("Productcategories")
.HasForeignKey("categorieId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Webshop.Domain.Entities.Product", "Product")
.WithMany("Productcategorys")
.WithMany("Productcategories")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Category");
b.Navigation("categorie");
b.Navigation("Product");
});
@@ -1192,13 +1192,13 @@ namespace Webshop.Infrastructure.Migrations
b.Navigation("Address");
});
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
{
b.Navigation("CategoryDiscounts");
b.Navigation("categorieDiscounts");
b.Navigation("Productcategorys");
b.Navigation("Productcategories");
b.Navigation("Subcategorys");
b.Navigation("Subcategories");
});
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
@@ -1212,7 +1212,7 @@ namespace Webshop.Infrastructure.Migrations
modelBuilder.Entity("Webshop.Domain.Entities.Discount", b =>
{
b.Navigation("CategoryDiscounts");
b.Navigation("categorieDiscounts");
b.Navigation("ProductDiscounts");
});
@@ -1226,7 +1226,7 @@ namespace Webshop.Infrastructure.Migrations
{
b.Navigation("ProductDiscounts");
b.Navigation("Productcategorys");
b.Navigation("Productcategories");
b.Navigation("Reviews");

View File

@@ -13,14 +13,14 @@ namespace Webshop.Infrastructure.Migrations
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "categorys",
name: "categories",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
Slug = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
ParentCategoryId = table.Column<Guid>(type: "uuid", nullable: true),
ParentcategorieId = table.Column<Guid>(type: "uuid", nullable: true),
ImageUrl = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
IsActive = table.Column<bool>(type: "boolean", nullable: false),
DisplayOrder = table.Column<int>(type: "integer", nullable: false),
@@ -29,11 +29,11 @@ namespace Webshop.Infrastructure.Migrations
},
constraints: table =>
{
table.PrimaryKey("PK_categorys", x => x.Id);
table.PrimaryKey("PK_categories", x => x.Id);
table.ForeignKey(
name: "FK_categorys_categorys_ParentCategoryId",
column: x => x.ParentCategoryId,
principalTable: "categorys",
name: "FK_categories_categories_ParentcategorieId",
column: x => x.ParentcategorieId,
principalTable: "categories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
@@ -154,25 +154,25 @@ namespace Webshop.Infrastructure.Migrations
});
migrationBuilder.CreateTable(
name: "CategoryDiscounts",
name: "categorieDiscounts",
columns: table => new
{
CategoryId = table.Column<Guid>(type: "uuid", nullable: false),
categorieId = table.Column<Guid>(type: "uuid", nullable: false),
DiscountId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CategoryDiscounts", x => new { x.CategoryId, x.DiscountId });
table.PrimaryKey("PK_categorieDiscounts", x => new { x.categorieId, x.DiscountId });
table.ForeignKey(
name: "FK_CategoryDiscounts_Discounts_DiscountId",
name: "FK_categorieDiscounts_Discounts_DiscountId",
column: x => x.DiscountId,
principalTable: "Discounts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CategoryDiscounts_categorys_CategoryId",
column: x => x.CategoryId,
principalTable: "categorys",
name: "FK_categorieDiscounts_categories_categorieId",
column: x => x.categorieId,
principalTable: "categories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
@@ -450,25 +450,25 @@ namespace Webshop.Infrastructure.Migrations
});
migrationBuilder.CreateTable(
name: "Productcategorys",
name: "Productcategories",
columns: table => new
{
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
CategoryId = table.Column<Guid>(type: "uuid", nullable: false)
categorieId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Productcategorys", x => new { x.ProductId, x.CategoryId });
table.PrimaryKey("PK_Productcategories", x => new { x.ProductId, x.categorieId });
table.ForeignKey(
name: "FK_Productcategorys_Products_ProductId",
name: "FK_Productcategories_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Productcategorys_categorys_CategoryId",
column: x => x.CategoryId,
principalTable: "categorys",
name: "FK_Productcategories_categories_categorieId",
column: x => x.categorieId,
principalTable: "categories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
@@ -594,18 +594,18 @@ namespace Webshop.Infrastructure.Migrations
column: "CustomerId");
migrationBuilder.CreateIndex(
name: "IX_CategoryDiscounts_DiscountId",
table: "CategoryDiscounts",
name: "IX_categorieDiscounts_DiscountId",
table: "categorieDiscounts",
column: "DiscountId");
migrationBuilder.CreateIndex(
name: "IX_categorys_ParentCategoryId",
table: "categorys",
column: "ParentCategoryId");
name: "IX_categories_ParentcategorieId",
table: "categories",
column: "ParentcategorieId");
migrationBuilder.CreateIndex(
name: "IX_categorys_Slug",
table: "categorys",
name: "IX_categories_Slug",
table: "categories",
column: "Slug",
unique: true);
@@ -669,9 +669,9 @@ namespace Webshop.Infrastructure.Migrations
column: "ShippingMethodId");
migrationBuilder.CreateIndex(
name: "IX_Productcategorys_CategoryId",
table: "Productcategorys",
column: "CategoryId");
name: "IX_Productcategories_categorieId",
table: "Productcategories",
column: "categorieId");
migrationBuilder.CreateIndex(
name: "IX_ProductDiscounts_DiscountId",
@@ -763,13 +763,13 @@ namespace Webshop.Infrastructure.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CategoryDiscounts");
name: "categorieDiscounts");
migrationBuilder.DropTable(
name: "OrderItems");
migrationBuilder.DropTable(
name: "Productcategorys");
name: "Productcategories");
migrationBuilder.DropTable(
name: "ProductDiscounts");
@@ -802,7 +802,7 @@ namespace Webshop.Infrastructure.Migrations
name: "ProductVariants");
migrationBuilder.DropTable(
name: "categorys");
name: "categories");
migrationBuilder.DropTable(
name: "Discounts");

View File

@@ -215,7 +215,7 @@ namespace Webshop.Infrastructure.Migrations
b.ToTable("Addresses");
});
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -246,7 +246,7 @@ namespace Webshop.Infrastructure.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<Guid?>("ParentCategoryId")
b.Property<Guid?>("ParentcategorieId")
.HasColumnType("uuid");
b.Property<string>("Slug")
@@ -256,27 +256,27 @@ namespace Webshop.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("ParentCategoryId");
b.HasIndex("ParentcategorieId");
b.HasIndex("Slug")
.IsUnique();
b.ToTable("categorys");
b.ToTable("categories");
});
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
modelBuilder.Entity("Webshop.Domain.Entities.categorieDiscount", b =>
{
b.Property<Guid>("CategoryId")
b.Property<Guid>("categorieId")
.HasColumnType("uuid");
b.Property<Guid>("DiscountId")
.HasColumnType("uuid");
b.HasKey("CategoryId", "DiscountId");
b.HasKey("categorieId", "DiscountId");
b.HasIndex("DiscountId");
b.ToTable("CategoryDiscounts");
b.ToTable("categorieDiscounts");
});
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
@@ -652,19 +652,19 @@ namespace Webshop.Infrastructure.Migrations
b.ToTable("Products");
});
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
modelBuilder.Entity("Webshop.Domain.Entities.Productcategorie", b =>
{
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<Guid>("CategoryId")
b.Property<Guid>("categorieId")
.HasColumnType("uuid");
b.HasKey("ProductId", "CategoryId");
b.HasKey("ProductId", "categorieId");
b.HasIndex("CategoryId");
b.HasIndex("categorieId");
b.ToTable("Productcategorys");
b.ToTable("Productcategories");
});
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
@@ -1003,31 +1003,31 @@ namespace Webshop.Infrastructure.Migrations
b.Navigation("Customer");
});
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
{
b.HasOne("Webshop.Domain.Entities.Category", "ParentCategory")
.WithMany("Subcategorys")
.HasForeignKey("ParentCategoryId")
b.HasOne("Webshop.Domain.Entities.categorie", "Parentcategorie")
.WithMany("Subcategories")
.HasForeignKey("ParentcategorieId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("ParentCategory");
b.Navigation("Parentcategorie");
});
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
modelBuilder.Entity("Webshop.Domain.Entities.categorieDiscount", b =>
{
b.HasOne("Webshop.Domain.Entities.Category", "Category")
.WithMany("CategoryDiscounts")
.HasForeignKey("CategoryId")
b.HasOne("Webshop.Domain.Entities.categorie", "categorie")
.WithMany("categorieDiscounts")
.HasForeignKey("categorieId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Webshop.Domain.Entities.Discount", "Discount")
.WithMany("CategoryDiscounts")
.WithMany("categorieDiscounts")
.HasForeignKey("DiscountId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Category");
b.Navigation("categorie");
b.Navigation("Discount");
});
@@ -1114,21 +1114,21 @@ namespace Webshop.Infrastructure.Migrations
b.Navigation("Supplier");
});
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
modelBuilder.Entity("Webshop.Domain.Entities.Productcategorie", b =>
{
b.HasOne("Webshop.Domain.Entities.Category", "Category")
.WithMany("Productcategorys")
.HasForeignKey("CategoryId")
b.HasOne("Webshop.Domain.Entities.categorie", "categorie")
.WithMany("Productcategories")
.HasForeignKey("categorieId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Webshop.Domain.Entities.Product", "Product")
.WithMany("Productcategorys")
.WithMany("Productcategories")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Category");
b.Navigation("categorie");
b.Navigation("Product");
});
@@ -1189,13 +1189,13 @@ namespace Webshop.Infrastructure.Migrations
b.Navigation("Address");
});
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
{
b.Navigation("CategoryDiscounts");
b.Navigation("categorieDiscounts");
b.Navigation("Productcategorys");
b.Navigation("Productcategories");
b.Navigation("Subcategorys");
b.Navigation("Subcategories");
});
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
@@ -1209,7 +1209,7 @@ namespace Webshop.Infrastructure.Migrations
modelBuilder.Entity("Webshop.Domain.Entities.Discount", b =>
{
b.Navigation("CategoryDiscounts");
b.Navigation("categorieDiscounts");
b.Navigation("ProductDiscounts");
});
@@ -1223,7 +1223,7 @@ namespace Webshop.Infrastructure.Migrations
{
b.Navigation("ProductDiscounts");
b.Navigation("Productcategorys");
b.Navigation("Productcategories");
b.Navigation("Reviews");

View File

@@ -1,4 +1,4 @@
// src/Webshop.Infrastructure/Repositories/CategoryRepository.cs
// src/Webshop.Infrastructure/Repositories/categorieRepository.cs
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
@@ -9,48 +9,48 @@ using Webshop.Infrastructure.Data;
namespace Webshop.Infrastructure.Repositories
{
public class CategoryRepository : ICategoryRepository
public class categorieRepository : IcategorieRepository
{
private readonly ApplicationDbContext _context;
public CategoryRepository(ApplicationDbContext context)
public categorieRepository(ApplicationDbContext context)
{
_context = context;
}
public async Task<IEnumerable<Category>> GetAllAsync()
public async Task<IEnumerable<categorie>> GetAllAsync()
{
return await _context.categorys.ToListAsync();
return await _context.categories.ToListAsync();
}
public async Task<Category?> GetByIdAsync(Guid id)
public async Task<categorie?> GetByIdAsync(Guid id)
{
return await _context.categorys.FindAsync(id);
return await _context.categories.FindAsync(id);
}
public async Task<Category?> GetBySlugAsync(string slug)
public async Task<categorie?> GetBySlugAsync(string slug)
{
return await _context.categorys.FirstOrDefaultAsync(c => c.Slug == slug);
return await _context.categories.FirstOrDefaultAsync(c => c.Slug == slug);
}
public async Task AddAsync(Category category)
public async Task AddAsync(categorie categorie)
{
_context.categorys.Add(category);
_context.categories.Add(categorie);
await _context.SaveChangesAsync();
}
public async Task UpdateAsync(Category category)
public async Task UpdateAsync(categorie categorie)
{
_context.categorys.Update(category);
_context.categories.Update(categorie);
await _context.SaveChangesAsync();
}
public async Task DeleteAsync(Guid id)
{
var category = await _context.categorys.FindAsync(id);
if (category != null)
var categorie = await _context.categories.FindAsync(id);
if (categorie != null)
{
_context.categorys.Remove(category);
_context.categories.Remove(categorie);
await _context.SaveChangesAsync();
}
}