using Koogle.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Koogle.Infrastructure.Data.Configurations; public class ExpenseConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("Expenses"); builder.HasKey(x => x.Id); builder.Property(x => x.ClubId) .IsRequired(); builder.Property(x => x.Name) .HasMaxLength(200) .IsRequired(); builder.Property(x => x.Description) .HasMaxLength(2000); builder.Property(x => x.Price) .HasPrecision(18, 2) .IsRequired(); builder.Property(x => x.IsOneClick).IsRequired(); builder.Property(x => x.IsInverse).IsRequired(); builder.Property(x => x.IsVariable).IsRequired(); builder.Property(x => x.ExpenseType) .HasConversion() .IsRequired(); builder.HasOne(x => x.Club) .WithMany() .HasForeignKey(x => x.ClubId) .OnDelete(DeleteBehavior.Restrict); // Alternate Key für Composite-FK in ExpenseTrigger: (Id, ClubId) builder.HasAlternateKey(x => new { x.Id, x.ClubId }); builder.HasIndex(x => x.ClubId); builder.HasQueryFilter(x => !x.IsDeleted); } }