using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SocialService.Domain.AggregatesModel.RelationshipAggregate;

namespace SocialService.Infrastructure.EntityConfigurations;

/// <summary>
/// EN: EF Core configuration for RelationshipType enumeration.
/// VI: Cấu hình EF Core cho RelationshipType enumeration.
/// </summary>
public class RelationshipTypeEntityTypeConfiguration : IEntityTypeConfiguration<RelationshipType>
{
    public void Configure(EntityTypeBuilder<RelationshipType> builder)
    {
        builder.ToTable("relationship_types");

        builder.HasKey(rt => rt.Id);

        builder.Property(rt => rt.Id)
            .HasColumnName("id")
            .ValueGeneratedNever();

        builder.Property(rt => rt.Name)
            .HasColumnName("name")
            .HasMaxLength(50)
            .IsRequired();

        // EN: Seed data for relationship types
        // VI: Seed data cho các loại quan hệ
        builder.HasData(
            RelationshipType.Friendship,
            RelationshipType.Following
        );
    }
}

/// <summary>
/// EN: EF Core configuration for RelationshipStatus enumeration.
/// VI: Cấu hình EF Core cho RelationshipStatus enumeration.
/// </summary>
public class RelationshipStatusEntityTypeConfiguration : IEntityTypeConfiguration<RelationshipStatus>
{
    public void Configure(EntityTypeBuilder<RelationshipStatus> builder)
    {
        builder.ToTable("relationship_statuses");

        builder.HasKey(rs => rs.Id);

        builder.Property(rs => rs.Id)
            .HasColumnName("id")
            .ValueGeneratedNever();

        builder.Property(rs => rs.Name)
            .HasColumnName("name")
            .HasMaxLength(50)
            .IsRequired();

        // EN: Seed data for relationship statuses
        // VI: Seed data cho các trạng thái quan hệ
        builder.HasData(
            RelationshipStatus.Pending,
            RelationshipStatus.Accepted,
            RelationshipStatus.Rejected,
            RelationshipStatus.Cancelled
        );
    }
}
