using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace FMSAdmin.Entities {
    public partial class FmsWorkOrder {
        public FmsWorkOrder() {
            FmsWorkOrderToFacility = new HashSet<FmsWorkOrderToFacility>();
        }

        [Key]
        public int SiteId { get; set; }
        [Key]
        public int WorkRequestId { get; set; }
        public int BusinessFieldId { get; set; }
        public int? EmergencyId { get; set; }
        [Required]
        [StringLength(24)]
        public string OrderUserId { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime OrderDate { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime StartWorkDate { get; set; }
        [Required]
        [StringLength(200)]
        public string Title { get; set; }
        [StringLength(2000)]
        public string Content { get; set; }

        [ForeignKey("BusinessFieldId")]
        [InverseProperty("FmsWorkOrder")]
        public virtual CmBusinessField CmBusinessField { get; set; }
        [ForeignKey("OrderUserId")]
        [InverseProperty("FmsWorkOrder")]
        public virtual CmUser CmUser { get; set; }
        [ForeignKey("SiteId,EmergencyId")]
        [InverseProperty("FmsWorkOrder")]
        public virtual FmsWorkCodeEmergency FmsWorkCodeEmergency { get; set; }
        [ForeignKey("SiteId,WorkRequestId")]
        [InverseProperty("FmsWorkOrder")]
        public virtual FmsWorkRequest FmsWorkRequest { get; set; }
        [ForeignKey(nameof(SiteId))]
        [InverseProperty(nameof(CmSite.FmsWorkOrder))]
        public virtual CmSite Site { get; set; }
        [InverseProperty("FmsWorkOrder")]
        public virtual FmsWorkResult FmsWorkResult { get; set; }
        [InverseProperty("FmsWorkOrder")]
        public virtual ICollection<FmsWorkOrderToFacility> FmsWorkOrderToFacility { get; set; }
    }
}
