using CMSMicroservice.Domain.Entities.Content;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace CMSMicroservice.Infrastructure.Persistence.Configurations.Content;

public class SitePageConfiguration : IEntityTypeConfiguration<SitePage>
{
    public void Configure(EntityTypeBuilder<SitePage> builder)
    {
        builder.ToTable("SitePages");
        builder.HasKey(x => x.Id);

        builder.Property(x => x.PageKey).IsRequired().HasMaxLength(50);
        builder.Property(x => x.Title).IsRequired().HasMaxLength(200);
        builder.Property(x => x.MetaDescription).HasMaxLength(300);
        builder.Property(x => x.HeroTitle).HasMaxLength(200);
        builder.Property(x => x.HeroSubtitle).HasMaxLength(500);
        builder.Property(x => x.HeroImagePath);
        builder.Property(x => x.IsActive).IsRequired().HasDefaultValue(true);

        // Indexes
        builder.HasIndex(x => x.PageKey).IsUnique().HasDatabaseName("IX_SitePages_PageKey");
    }
}
