using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Runtime.Serialization; using System.Threading; using System.Web; using Newtonsoft.Json; using Resources; namespace Weee.Models.Paramemter { [Table("SimaproParameters")] public class SimaproParameter : Parameter { public SimaproParameter() { CreateTime = DateTime.UtcNow; } public string Encoding { get; set; } public override decimal Value { get; set; } public string Unit { get; set; } public string Remark { get; set; } public string Database { get; set; } public string Description { get; set; } [Column(TypeName = "DateTime2")] public DateTime CreateTime { get; set; } public int TypeID { get; set; } [ForeignKey("TypeID")] [JsonIgnore][IgnoreDataMember] public virtual SimaproParameterType Type { get; set; } [NotMapped] public string DisplayName { get { if (Thread.CurrentThread.CurrentUICulture.LCID == new System.Globalization.CultureInfo("zh-CN").LCID) { return string.IsNullOrEmpty(DisplayNameCN) ? DisplayNameTW : DisplayNameCN; } else if (Thread.CurrentThread.CurrentUICulture.LCID == new System.Globalization.CultureInfo("en-US").LCID) { return string.IsNullOrEmpty(DisplayNameEN) ? DisplayNameTW : DisplayNameEN; } return DisplayNameTW; } } [Required(ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "RequiredMessage")] [StringLength(200, ErrorMessageResourceType = typeof(Resource), ErrorMessageResourceName = "MaxLengthMessage200")] [Display(Name = "MultiLanguageDisplayNameTW", ResourceType = typeof(Resource))] public string DisplayNameTW { get; set; } [Display(Name = "MultiLanguageDisplayNameCN", ResourceType = typeof(Resource))] public string DisplayNameCN { get; set; } [Display(Name = "MultiLanguageDisplayNameEN", ResourceType = typeof(Resource))] public string DisplayNameEN { get; set; } } }