using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using NetTopologySuite.Geometries;

namespace labdb.Models;

public record CityId : EntityIdBase<CityId>;

public class City : EntityBase<CityId>
{
    public string Name { get; set; } = null!;
    public string? EnglishName { get; set; }
    public CountryId CountryId { get; set; } = null!;
    public Country Country { get; set; } = null!;
    public Point Location { get; set; } = null!;

}

public class CityConfiguration : EntityBaseConfiguration<City, CityId>
{
    public override void Configure(EntityTypeBuilder<City> builder)
    {
        base.Configure(builder);

        builder.HasIndex(x => x.Name, "name").IsUnique();
        builder.HasIndex(x => x.Name, "name_trgm").HasMethod("gin").HasOperators("gin_trgm_ops");
        builder.HasIndex(x => x.EnglishName, "english_name").IsUnique();
        builder.HasIndex(x => x.EnglishName, "english_name_trgm").HasMethod("gin").HasOperators("gin_trgm_ops");
    }
}