// EN: ProductType enumeration entity configuration.
// VI: Cấu hình entity cho ProductType enumeration.

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using CatalogService.Domain.AggregatesModel.ProductAggregate;

namespace CatalogService.Infrastructure.EntityConfigurations;

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

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

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

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

        // EN: Seed data for ProductType
        // VI: Dữ liệu seed cho ProductType
        builder.HasData(
            ProductType.Physical,
            ProductType.Service,
            ProductType.PreparedFood
        );
    }
}
