using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using FacebookService.Domain.AggregatesModel.ConversationAggregate;

namespace FacebookService.Infrastructure.EntityConfigurations;

/// <summary>
/// EN: EF Core configuration for ConversationStatus enumeration.
/// VI: Cấu hình EF Core cho enumeration ConversationStatus.
/// </summary>
public class ConversationStatusEntityTypeConfiguration : IEntityTypeConfiguration<ConversationStatus>
{
    public void Configure(EntityTypeBuilder<ConversationStatus> builder)
    {
        builder.ToTable("conversation_statuses");
        builder.HasKey(s => s.Id);
        builder.Property(s => s.Id).ValueGeneratedNever();
        builder.Property(s => s.Name).HasMaxLength(50).IsRequired();

        // EN: Seed data / VI: Dữ liệu khởi tạo
        builder.HasData(
            ConversationStatus.Active,
            ConversationStatus.Closed,
            ConversationStatus.Archived
        );
    }
}

/// <summary>
/// EN: EF Core configuration for MessageType enumeration.
/// VI: Cấu hình EF Core cho enumeration MessageType.
/// </summary>
public class MessageTypeEntityTypeConfiguration : IEntityTypeConfiguration<MessageType>
{
    public void Configure(EntityTypeBuilder<MessageType> builder)
    {
        builder.ToTable("message_types");
        builder.HasKey(t => t.Id);
        builder.Property(t => t.Id).ValueGeneratedNever();
        builder.Property(t => t.Name).HasMaxLength(50).IsRequired();

        // EN: Seed data / VI: Dữ liệu khởi tạo
        builder.HasData(
            MessageType.Text,
            MessageType.Image,
            MessageType.Video,
            MessageType.Audio,
            MessageType.File,
            MessageType.Template,
            MessageType.QuickReply
        );
    }
}

/// <summary>
/// EN: EF Core configuration for MessageDirection enumeration.
/// VI: Cấu hình EF Core cho enumeration MessageDirection.
/// </summary>
public class MessageDirectionEntityTypeConfiguration : IEntityTypeConfiguration<MessageDirection>
{
    public void Configure(EntityTypeBuilder<MessageDirection> builder)
    {
        builder.ToTable("message_directions");
        builder.HasKey(d => d.Id);
        builder.Property(d => d.Id).ValueGeneratedNever();
        builder.Property(d => d.Name).HasMaxLength(50).IsRequired();

        // EN: Seed data / VI: Dữ liệu khởi tạo
        builder.HasData(
            MessageDirection.Incoming,
            MessageDirection.Outgoing
        );
    }
}
