labdb/Models/Lab.cs
2022-11-10 21:33:45 +01:00

47 lines
1.5 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using NetTopologySuite.Geometries;
namespace labdb.Models;
public record LabId : EntityIdBase<LabId>;
public class Lab : EntityBase<LabId>
{
public string Name { get; set; } = null!;
public string? Website { get; set; }
public string? Phone { get; set; }
public string? Email { get; set; }
public string? AddressLine1 { get; set; }
public string? AddressLine2 { get; set; }
public string? AddressPostcode { get; set; }
public string? AddressCity { get; set; }
public CountryId CountryId { get; set; } = null!;
public Country Country { get; set; } = null!;
public Point? Location { get; set; }
public bool RequiresAppointment { get; set; }
public bool SelfDraw { get; set; }
public decimal BasicFee { get; set; }
public decimal DrawFee { get; set; }
public string? Notes { get; set; }
}
public class LabConfiguration : EntityBaseConfiguration<Lab, LabId>
{
public override void Configure(EntityTypeBuilder<Lab> builder)
{
base.Configure(builder);
builder.HasIndex(x => x.Name, "name");
builder.HasIndex(x => x.Name, "name_trgm").HasMethod("gin").HasOperators("gin_trgm_ops");
builder.HasIndex(x => x.AddressPostcode);
builder.HasIndex(x => x.AddressCity);
builder.HasIndex(x => x.RequiresAppointment);
builder.HasIndex(x => x.SelfDraw);
builder.HasIndex(x => x.BasicFee);
builder.HasIndex(x => x.DrawFee);
}
}