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

namespace FMSAdmin.Entities {
    public partial class FmsWorkRequest {
        public FmsWorkRequest() {
            FmsWorkRequestToFacility = new HashSet<FmsWorkRequestToFacility>();
            FmsWorkRequestToAccident = new HashSet<FmsWorkRequestToAccident>();
            FmsWorkRequestToComplaint = new HashSet<FmsWorkRequestToComplaint>();
        }

        [Key]
        public int SiteId { get; set; }
        [Key]
        public int WorkRequestId { get; set; }
        public int WorkTypeId { get; set; }

        public int? WorkDetailTypeId { get; set; }
        public int BusinessFieldId { get; set; }
        public int? WorkScheduleId { get; set; }
        public int WorkProgressId { get; set; }
        [Required]
        [StringLength(200)]
        public string Title { get; set; }
        [StringLength(1024)]
        public string Content { get; set; }
        [StringLength(24)]
        public string RequestUserId { get; set; }
        [Column(TypeName = "datetime")]

        public DateTime RequestDate { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime StartWorkDate { get; set; }
        [StringLength(24)]
        public string RejectUserId { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime? RejectDate { get; set; }
        [StringLength(512)]
        public string RejectReason { get; set; }
        public int? InspectionAgencyId { get; set; }

        public string WorkUsers { get; set; }
        public string WorkDate { get; set; }

        public int? WorkPartnerId { get; set; }
        public string WorkPartnerName { get; set; }

        public string WorkItem { get; set; }

        [Column(TypeName = "numeric(15, 0)")]
        public decimal? WorkPrice { get; set; }

        [Column(TypeName = "datetime")]
        public DateTime? WorkEndDate { get; set; }

        public int? FileId { get; set; }

        [ForeignKey("SiteId,FileId")]
        public virtual CmFile CmFile { get; set; }

        [ForeignKey("SiteId,WorkPartnerId")]
        public virtual CmPartner WorkPartner { get; set; }

        [ForeignKey("BusinessFieldId")]
        [InverseProperty("FmsWorkRequest")]
        public virtual CmBusinessField CmBusinessField { get; set; }
        [ForeignKey("SiteId,InspectionAgencyId")]
        [InverseProperty("FmsWorkRequest")]
        public virtual CmPartner CmPartner { get; set; }
        [ForeignKey("RejectUserId")]
        [InverseProperty("FmsWorkRequestCmUser")]
        public virtual CmUser CmUser { get; set; }
        [ForeignKey("RequestUserId")]
        [InverseProperty("FmsWorkRequestCmUserNavigation")]
        public virtual CmUser CmUserNavigation { get; set; }
        [ForeignKey("SiteId,WorkScheduleId")]
        [InverseProperty("FmsWorkRequest")]
        public virtual FmsWorkSchedule FmsWorkSchedule { get; set; }
        [ForeignKey(nameof(SiteId))]
        [InverseProperty(nameof(CmSite.FmsWorkRequest))]
        public virtual CmSite Site { get; set; }
        [ForeignKey(nameof(WorkProgressId))]
        [InverseProperty(nameof(FmsWorkCodeProgress.FmsWorkRequest))]
        public virtual FmsWorkCodeProgress WorkProgress { get; set; }
        [ForeignKey(nameof(WorkTypeId))]
        [InverseProperty(nameof(FmsWorkCodeType.FmsWorkRequest))]
        public virtual FmsWorkCodeType WorkType { get; set; }
        [ForeignKey(nameof(WorkDetailTypeId))]
        public virtual FmsWorkCodeDetailType WorkDetailType { get; set; }
        [InverseProperty("FmsWorkRequest")]
        public virtual FmsWorkOrder FmsWorkOrder { get; set; }
        [InverseProperty("FmsWorkRequest")]
        public virtual FmsWorkResult FmsWorkResult { get; set; }
        [InverseProperty("FmsWorkRequest")]
        public virtual ICollection<FmsWorkRequestToFacility> FmsWorkRequestToFacility { get; set; }
        [InverseProperty("FmsWorkRequest")]
        public virtual ICollection<FmsWorkRequestToAccident> FmsWorkRequestToAccident { get; set; }
        [InverseProperty("FmsWorkRequest")]
        public virtual ICollection<FmsWorkRequestToComplaint> FmsWorkRequestToComplaint { get; set; }
    }
}
