using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Core.Objects; using System.Linq; using System.Web; using System.Runtime.Serialization; using Resources; using Newtonsoft.Json; using Weee.Models.Survey_form_metadata; using Weee.Models.ExtensionMethods; namespace Weee.Models { [Table("ProductLCAFabSurveyResult")] public class SnapShotSurveyResult { public SnapShotSurveyResult() { } public SnapShotSurveyResult(ProductLCA Source, Product TargetProduct) { //CreateDate = DateTime.UtcNow;//DL-13 CreateDate = DateTime.Now;//DL-13 SnapShotFabProductionArea = Source.FabProductionArea; SnapShotFabProductionHour = Source.FabProductionHour; SnapShotFabProductionWeight = Source.FabProductionWeight; SnapShotProductProductionPcs = Source.ProductProductionPcs; SnapShotProductProductionHour = Source.ProductProductionHour; SnapShotProductAreaSize = TargetProduct.AreaSize; SnapShotProductWeight = TargetProduct.Weight; SourceLCA = Source; Source.SnapShotSurveyResult = this; } public int ID { get; set; } [Column(TypeName = "DateTime2")] public DateTime CreateDate { get; set; } public decimal Scope1FabResult { get; set; } public decimal Scope2FabResult { get; set; } public decimal Scope3FabResult { get; set; } public decimal SecondaryWasteResult { get; set; } public decimal SecondaryWasteTransportResult { get; set; } public decimal SecondaryDirectMaterialResult { get; set; } public decimal SecondaryIndirectMaterialResult { get; set; } public decimal SecondaryWrapMaterialResult { get; set; } public decimal SecondaryTransportResult { get; set; } public decimal? SnapShotFabProductionWeight { get; set; } public decimal? SnapShotFabProductionArea { get; set; } public decimal? SnapShotFabProductionHour { get; set; } public decimal? SnapShotProductProductionHour { get; set; } public decimal? SnapShotProductWeight { get; set; } public decimal? SnapShotProductAreaSize { get; set; } public decimal? SnapShotProductProductionPcs { get; set; } [NotMapped] public decimal? constantFactorInWeight { get { if (SnapShotProductWeight.HasValue && SnapShotFabProductionWeight.HasValue && SnapShotFabProductionWeight.Value > 0) { return SnapShotProductWeight.Value / SnapShotFabProductionWeight.Value; } return null; } } [NotMapped] public decimal? constantFactorInArea { get { if (SnapShotProductAreaSize.HasValue && SnapShotFabProductionArea.HasValue && SnapShotFabProductionArea.Value > 0) { return SnapShotProductAreaSize.Value / SnapShotFabProductionArea.Value; } return null; } } [NotMapped] public decimal? constantFactorInWorkHour { get { if (SnapShotProductProductionHour.HasValue && SnapShotFabProductionHour.HasValue && SnapShotProductProductionPcs.HasValue && SnapShotFabProductionHour.Value > 0 && SnapShotProductProductionPcs.Value > 0) { return SnapShotProductProductionHour.Value / (SnapShotFabProductionHour.Value * SnapShotProductProductionPcs.Value); } return null; } } [JsonIgnore] [IgnoreDataMember] public virtual ProductLCA SourceLCA { get; set; } } }