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

namespace FMSAdmin.Entities {
    public partial class FmsMaterialPurchaseOrder {
        public FmsMaterialPurchaseOrder() {
            FmsMaterialPurchaseOrderMaterial = new HashSet<FmsMaterialPurchaseOrderMaterial>();
            FmsMaterialStored = new HashSet<FmsMaterialStored>();
        }

        [Key]
        public int SiteId { get; set; }
        public int BusinessFieldId { get; set; }
        [Key]
        public int PurchaseOrderId { get; set; }
        public int PurchaseRequestId { get; set; }
        public int? TradeCompanyId { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime OrderDate { get; set; }
        [Required]
        [StringLength(24)]
        public string OrderUserId { get; set; }
        [Required]
        [StringLength(256)]
        public string Title { get; set; }
        [StringLength(2000)]
        public string Reason { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime? StoredDueDate { get; set; }
        public int? FileId { get; set; }

        [ForeignKey("BusinessFieldId")]
        [InverseProperty("FmsMaterialPurchaseOrder")]
        public virtual CmBusinessField CmBusinessField { get; set; }
        [ForeignKey("SiteId,FileId")]
        [InverseProperty("FmsMaterialPurchaseOrder")]
        public virtual CmFile CmFile { get; set; }
        [ForeignKey("OrderUserId")]
        [InverseProperty("FmsMaterialPurchaseOrder")]
        public virtual CmUser CmUser { get; set; }
        [ForeignKey("SiteId,PurchaseRequestId")]
        [InverseProperty("FmsMaterialPurchaseOrder")]
        public virtual FmsMaterialPurchaseRequest FmsMaterialPurchaseRequest { get; set; }
        [ForeignKey("SiteId,TradeCompanyId")]
        [InverseProperty("FmsMaterialPurchaseOrder")]
        public virtual FmsMaterialTradeCompany FmsMaterialTradeCompany { get; set; }
        [ForeignKey(nameof(SiteId))]
        [InverseProperty(nameof(CmSite.FmsMaterialPurchaseOrder))]
        public virtual CmSite Site { get; set; }
        [InverseProperty("FmsMaterialPurchaseOrder")]
        public virtual ICollection<FmsMaterialPurchaseOrderMaterial> FmsMaterialPurchaseOrderMaterial { get; set; }
        [InverseProperty("FmsMaterialPurchaseOrder")]
        public virtual ICollection<FmsMaterialStored> FmsMaterialStored { get; set; }
    }
}
