using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using OnProfNext.Shared.Models; namespace OnProfNext.Server.Data.Configurations { public class BookingConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("Bookings"); builder.HasKey(b => b.Id); builder.Property(b => b.Hours) .HasColumnType("decimal(5,2)") .IsRequired(); builder.Property(b => b.Date) .IsRequired(); builder.Property(b => b.Description) .HasMaxLength(500); builder.Property(b => b.MandantId) .IsRequired(); builder.HasOne(b => b.Order) .WithMany() .HasForeignKey(b => b.OrderId) .OnDelete(DeleteBehavior.Cascade); builder.HasOne(b => b.User) .WithMany() .HasForeignKey(b => b.UserId) .OnDelete(DeleteBehavior.Restrict); builder.Property(b => b.CreatedAt) .HasDefaultValueSql("GETUTCDATE()"); builder.Property(b => b.UpdatedAt) .HasDefaultValueSql("GETUTCDATE()"); } } }