using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using IndexAttribute = Microsoft.EntityFrameworkCore.IndexAttribute;

namespace Elwig.Models.Entities {
    [Table("branch"), PrimaryKey("ZwstId"), Index("Name", IsUnique = true)]
    public class Branch {
        [Column("zwstid")]
        public required string ZwstId { get; set; }

        [Column("name")]
        public required string Name { get; set; }

        [Column("country")]
        public int? CountryNum { get; set; }

        [Column("postal_dest")]
        public string? PostalDestId { get; set; }

        [Column("address")]
        public string? Address { get; set; }

        [ForeignKey("CountryNum")]
        public virtual Country? Country { get; private set; }

        [ForeignKey("CountryNum, PostalDestId")]
        public virtual PostalDest? PostalDest { get; private set; }

        [Column("phone_nr")]
        public string? PhoneNr { get; set; }

        [Column("fax_nr")]
        public string? FaxNr { get; set; }

        [Column("mobile_nr")]
        public string? MobileNr { get; set; }

        [InverseProperty(nameof(Member.Branch))]
        public virtual ICollection<Member> Members { get; private set; } = null!;
    }
}
