using Koogle.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Koogle.Infrastructure.Data.Configurations; /// /// EF Core configuration for BookingCategory entity. /// public class BookingCategoryConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("BookingCategories"); builder.HasKey(x => x.Id); builder.Property(x => x.ClubId) .IsRequired(); builder.Property(x => x.Name) .HasMaxLength(100) .IsRequired(); builder.Property(x => x.Description) .HasMaxLength(500); builder.Property(x => x.CategoryType) .HasConversion() .IsRequired(); builder.Property(x => x.IsSystemCategory) .IsRequired(); builder.Property(x => x.Color) .HasMaxLength(7); // #RRGGBB builder.Property(x => x.Icon) .HasMaxLength(50); builder.Property(x => x.IsActive) .IsRequired(); builder.HasOne(x => x.Club) .WithMany(c => c.BookingCategories) .HasForeignKey(x => x.ClubId) .OnDelete(DeleteBehavior.NoAction); builder.HasAlternateKey(x => new { x.Id, x.ClubId }); builder.HasIndex(x => x.ClubId); builder.HasIndex(x => new { x.ClubId, x.Name }) .HasFilter("[IsDeleted] = 0") .IsUnique(); builder.HasQueryFilter(x => !x.IsDeleted); } }