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 { public abstract class LCA { public LCA() { //LCAname = ""; StartDate = DateTime.UtcNow; EndDate = DateTime.UtcNow; StatusHistory = new HashSet(); Status = LCAStatus.New; //CreatedDate = DateTime.UtcNow; CreatedDate = DateTime.Now;//DL-13 Comments = new HashSet(); WorkHourSheet = new HashSet(); KitchenSheet = new HashSet(); GasolineEquipmentSheet = new HashSet(); FireEquipmentSheet = new HashSet(); VehicleSheet = new HashSet(); RefrigerantSheet = new HashSet(); PowerUsageSheet = new HashSet(); SteamUsageSheet = new HashSet(); } [DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key] [Display(Name = "LCAid", ResourceType = typeof(Resource))] public int ID { get; set; } //[JsonIgnore] //[IgnoreDataMember] [Display(Name = "LCAname", ResourceType = typeof(Resource))] public string LCAname { get; set; } public string LCAStarter { get; set; } [Display(Name = "UserDepartment", ResourceType = typeof(Resource))] public string LCAStarterDepartment { get; set; } [Display(Name = "UserPhoneNumber", ResourceType = typeof(Resource))] public string LCAStarterPhone { get; set; } [Display(Name = "UserJob", ResourceType = typeof(Resource))] public string LCAStarterJob { get; set; } [Display(Name = "UserEmail", ResourceType = typeof(Resource))] public string LCAStarterEmail { get; set; } public string InterrogationResultUrl { get; set; } public string ProductInventoryResultUrl { get; set; } public string CarbonFootprintDocxUrl { get; set; } public string CertificationFeedbackZipUrl { get; set; }//CFT-89 public string UploadZipReportUrl { get; set; }//CFT-89 [Column(TypeName = "DateTime2")] [Display(Name = "LCACreatedDate", ResourceType = typeof(Resource))] [DisplayFormat(DataFormatString = "{0:yyyy/MM/dd HH:mm:ss}", ApplyFormatInEditMode = true)] public DateTime CreatedDate { get; set; } [Column(TypeName = "DateTime2")] [Display(Name = "LCAStartDate", ResourceType = typeof(Resource))] [Required(ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "RequiredMessage")] public DateTime StartDate { get; set; } [Column(TypeName = "DateTime2")] [Display(Name = "LCAEndDate", ResourceType = typeof(Resource))] [Required(ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "RequiredMessage")] public DateTime EndDate { get; set; } [Display(Name = "LCADeadLine", ResourceType = typeof(Resource))] public DateTime? DeadLine { get; set; } [Display(Name = "LCADescription", ResourceType = typeof(Resource))] [MaxLength(200, ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "LCADescriptionMaxLength")] public string Description { get; set; } [Display(Name = "CustomerPartNumber", ResourceType = typeof(Resource))] public string CustomerPartNumber { get; set; } [InverseProperty("CommentTarget")] [JsonIgnore] [IgnoreDataMember] public virtual ICollection Comments { get; set; } [InverseProperty("OwnerLCA")] [JsonIgnore] [IgnoreDataMember] public virtual ICollection WorkHourSheet { get; set; } [InverseProperty("OwnerLCA")] [JsonIgnore] [IgnoreDataMember] public virtual ICollection KitchenSheet { get; set; } [InverseProperty("OwnerLCA")] [JsonIgnore] [IgnoreDataMember] public virtual ICollection GasolineEquipmentSheet { get; set; } [InverseProperty("OwnerLCA")] [JsonIgnore] [IgnoreDataMember] public virtual ICollection FireEquipmentSheet { get; set; } [InverseProperty("OwnerLCA")] [JsonIgnore] [IgnoreDataMember] public virtual ICollection VehicleSheet { get; set; } [InverseProperty("OwnerLCA")] [JsonIgnore] [IgnoreDataMember] public virtual ICollection RefrigerantSheet { get; set; } [InverseProperty("OwnerLCA")] [JsonIgnore] [IgnoreDataMember] public virtual ICollection PowerUsageSheet { get; set; } [InverseProperty("OwnerLCA")] [JsonIgnore] [IgnoreDataMember] public virtual ICollection SteamUsageSheet { get; set; } [NotMapped] [Display(Name = "LCAType", ResourceType = typeof(Resource))] public Type LCAType { get { return ObjectContext.GetObjectType(this.GetType()); } } [NotMapped] public string LCATypeDisplayName { get { if (this.LCAType == typeof(OrganizationLCA)) { return Resource.StaticLabelOrganizationLCA; } else if (this.LCAType == typeof(ProductLCA)) { return Resource.StaticLabelProductLCA; } else { return Resource.StaticLabelChildProductLCA; } } } public int? OwnerID { get; set; } [ForeignKey("OwnerID")] [JsonIgnore] [IgnoreDataMember] [Display(Name = "LCAOwner", ResourceType = typeof(Resource))] public virtual NormalCompany Owner { get; set; } public int? VerifierCompanyID { get; set; } [ForeignKey("VerifierCompanyID")] [Display(Name = "CertificationUnit", ResourceType = typeof(Resource))] [JsonIgnore] [IgnoreDataMember] public virtual CertificationCompany VerifyBy { get; set; } [Display(Name = "LCAStatus", ResourceType = typeof(Resource))] public LCAStatus Status { get; set; } [NotMapped] public string StatusDisplayName { get { return Status.DisplayString(); } } [JsonIgnore] [IgnoreDataMember] [InverseProperty("LCA")] public virtual ICollection StatusHistory { get; set; } } }