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

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

        [Key]
        public int SiteId { get; set; }
        public int BusinessFieldId { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime ReleaseDate { get; set; }
        [Key]
        public int MaterialReleaseId { get; set; }
        public short ReleaseTypeId { get; set; }
        public int? WorkRequestId { get; set; }
        public int? CheckItemMaterialId { get; set; }
        public int? WarehouseId { get; set; }
        public int? MaterialId { get; set; }
        public int? MaterialCount { get; set; }
        public int? StockCountByPoint { get; set; }
        public int? ReleaseTotalCost { get; set; }
        public short AdjustmentTypeId { get; set; }
        [StringLength(24)]
        public string AdjustmentUserId { get; set; }
        [StringLength(24)]
        public string ConfirmedUserId { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime? ConfirmedDate { get; set; }
        public bool IsConfirmed { get; set; }
        [StringLength(1024)]
        public string Comment { get; set; }

        [ForeignKey(nameof(AdjustmentTypeId))]
        [InverseProperty(nameof(FmsMaterialCodeAdjustmentType.FmsMaterialRelease))]
        public virtual FmsMaterialCodeAdjustmentType AdjustmentType { get; set; }
        [ForeignKey("BusinessFieldId")]
        [InverseProperty("FmsMaterialRelease")]
        public virtual CmBusinessField CmBusinessField { get; set; }
        [ForeignKey("AdjustmentUserId")]
        [InverseProperty("FmsMaterialReleaseCmUser")]
        public virtual CmUser CmUser { get; set; }
        [ForeignKey("ConfirmedUserId")]
        [InverseProperty("FmsMaterialReleaseCmUserNavigation")]
        public virtual CmUser CmUserNavigation { get; set; }
        [ForeignKey("SiteId,MaterialId")]
        [InverseProperty("FmsMaterialRelease")]
        public virtual FmsMaterial FmsMaterial { get; set; }
        [ForeignKey("SiteId,WorkRequestId")]
        [InverseProperty("FmsMaterialRelease")]
        public virtual FmsWorkResult FmsWorkResult { get; set; }
        [ForeignKey(nameof(ReleaseTypeId))]
        [InverseProperty(nameof(FmsMaterialCodeReleaseType.FmsMaterialRelease))]
        public virtual FmsMaterialCodeReleaseType ReleaseType { get; set; }
        [ForeignKey(nameof(SiteId))]
        [InverseProperty(nameof(CmSite.FmsMaterialRelease))]
        public virtual CmSite Site { get; set; }

        [ForeignKey("CheckItemMaterialId")]
        [InverseProperty("FmsMaterialRelease")]
        public virtual FmsWorkResultCheckItemMaterial FmsWorkResultCheckItemMaterial { get; set; }

        [InverseProperty("FmsMaterialRelease")]
        public virtual ICollection<FmsMaterialReleaseDetail> FmsMaterialReleaseDetail { get; set; }

        [ForeignKey("SiteId,WarehouseId")]
        [InverseProperty("FmsMaterialRelease")]
        public virtual FmsMaterialWarehouse FmsMaterialWarehouse { get; set; }

        [NotMapped]
        public virtual ICollection<FmsMaterialRelease> MaterialReleaseList { get; set; }
    }
}
