using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace AsbCloudDb.Model
{
    [Table("t_well"), Comment("скважины")]
    public partial class Well : IId, IMapPoint
    {
        [Key]
        [Column("id")]
        public int Id { get; set; }

        [Column("caption")]
        [StringLength(255)]
        public string Caption { get; set; } = null!;

        [Column("id_cluster")]
        public int IdCluster { get; set; }

        [Column("id_telemetry")]
        public int? IdTelemetry { get; set; }

        [Column("id_well_type")]
        public int IdWellType { get; set; }

        [Column("state"), Comment("0 - неизвестно, 1 - в работе, 2 - завершена")]
        public int IdState { get; set; }

        [Column("latitude")]
        public double? Latitude { get; set; }

        [Column("longitude")]
        public double? Longitude { get; set; }

        [Column("timezone", TypeName = "jsonb"), Comment("Смещение часового пояса от UTC")]
        public SimpleTimezone Timezone { get; set; } = null!;

        [ForeignKey(nameof(IdWellType))]
        [InverseProperty(nameof(Model.WellType.Wells))]
        public virtual WellType WellType { get; set; } = null!;

        [InverseProperty(nameof(RelationCompanyWell.Well))]
        public virtual ICollection<RelationCompanyWell> RelationCompaniesWells { get; set; } = null!;

        [ForeignKey(nameof(IdCluster))]
        [InverseProperty(nameof(Model.Cluster.Wells))]
        public virtual Cluster Cluster { get; set; } = null!;

        [ForeignKey(nameof(IdTelemetry))]
        [InverseProperty(nameof(Model.Telemetry.Well))]
        public virtual Telemetry? Telemetry { get; set; }

        [JsonIgnore]
        [InverseProperty(nameof(WellOperation.Well))]
        public virtual ICollection<WellOperation> WellOperations { get; set; } = null!;

        [InverseProperty(nameof(WellComposite.Well))]
        public virtual ICollection<WellComposite> WellComposites { get; set; } = null!;

        [InverseProperty(nameof(WellComposite.WellSrc))]
        public virtual ICollection<WellComposite> WellCompositeSrcs { get; set; } = null!;

        [InverseProperty(nameof(DrillingProgramPart.Well))]
        public virtual ICollection<DrillingProgramPart> DrillingProgramParts { get; set; } = null!;

        [InverseProperty(nameof(Contact.Well))]
        public virtual ICollection<Contact> Contacts { get; set; } = null!;
    }
}