using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SolutionErp.Domain.Hrm;

namespace SolutionErp.Infrastructure.Persistence.Configurations;

// EF Mig 44 P11-C (S51) — Danh mục xe công. Catalog standalone, no FK.
// UNIQUE Code filtered WHERE IsDeleted=0 (gotcha #57 — soft-deleted slot reusable,
// khớp app-level !IsDeleted check + pattern HolidayConfiguration/Catalogs/Contract/PE).
public class VehicleConfiguration : IEntityTypeConfiguration<Vehicle>
{
    public void Configure(EntityTypeBuilder<Vehicle> e)
    {
        e.ToTable("Vehicles");

        e.Property(x => x.Code).HasMaxLength(50).IsRequired();
        e.Property(x => x.Name).HasMaxLength(200).IsRequired();
        e.Property(x => x.LicensePlate).HasMaxLength(20).IsRequired();
        e.Property(x => x.Description).HasMaxLength(500);

        e.HasIndex(x => x.Code).IsUnique().HasFilter("[IsDeleted] = 0");
    }
}
