using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace GeoRitmMover.Mover.Data.EntityConfigurations;
public class ZoneMapEntityConfiguration : IEntityTypeConfiguration<ZoneMap>
{
	public void Configure(EntityTypeBuilder<ZoneMap> builder)
	{
		_ = builder.HasKey(x => x.Id);

		_ = builder.Property(x => x.From)
			.IsRequired();
		_ = builder.HasIndex(x => x.From).IsUnique();

		_ = builder.Property(x => x.To)
			.IsRequired()
			.HasConversion(x => x.Value, x => new(x));
		_ = builder.HasIndex(x => x.To).IsUnique();
	}
}
