// EN: Entity type configuration for Resource.
// VI: Cấu hình entity type cho Resource.

using BookingService.Domain.AggregatesModel.ResourceAggregate;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace BookingService.Infrastructure.EntityConfigurations;

/// <summary>
/// EN: Entity type configuration for Resource aggregate.
/// VI: Cấu hình entity type cho aggregate Resource.
/// </summary>
public class ResourceEntityTypeConfiguration : IEntityTypeConfiguration<Resource>
{
    public void Configure(EntityTypeBuilder<Resource> builder)
    {
        builder.ToTable("resources");
        
        builder.HasKey(r => r.Id);
        builder.Property(r => r.Id)
            .HasColumnName("id")
            .ValueGeneratedNever();

        builder.Property<Guid>("_shopId")
            .HasColumnName("shop_id")
            .IsRequired();

        builder.Property<string>("_name")
            .HasColumnName("name")
            .HasMaxLength(200)
            .IsRequired();

        builder.Property<string>("_resourceType")
            .HasColumnName("resource_type")
            .HasMaxLength(50)
            .IsRequired();

        builder.Property<int>("_capacity")
            .HasColumnName("capacity")
            .IsRequired();

        builder.Property<bool>("_isActive")
            .HasColumnName("is_active")
            .IsRequired();

        builder.Property<DateTime>("_createdAt")
            .HasColumnName("created_at")
            .IsRequired();

        // EN: Indexes / VI: Indexes
        builder.HasIndex("_shopId")
            .HasDatabaseName("ix_resources_shop_id");

        // EN: Ignore public properties (mapped via backing fields)
        // VI: Bỏ qua các properties công khai (đã map qua backing fields)
        builder.Ignore(r => r.ShopId);
        builder.Ignore(r => r.Name);
        builder.Ignore(r => r.ResourceType);
        builder.Ignore(r => r.Capacity);
        builder.Ignore(r => r.IsActive);
        builder.Ignore(r => r.CreatedAt);
    }
}
