100 lines
3.7 KiB
C#
100 lines
3.7 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using System.ComponentModel.DataAnnotations.Schema;
|
|||
|
using System.Linq;
|
|||
|
using System.Runtime.Serialization;
|
|||
|
using System.Web;
|
|||
|
using Newtonsoft.Json;
|
|||
|
using Resources;
|
|||
|
|
|||
|
namespace Weee.Models
|
|||
|
{
|
|||
|
public class Fab : IValidatableObject
|
|||
|
{
|
|||
|
public Fab()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|||
|
[Key]
|
|||
|
public int ID { get; set; }
|
|||
|
|
|||
|
[Display(Name = "FabName", ResourceType = typeof(Resource))]
|
|||
|
//[Required(ErrorMessageResourceType = typeof(Resource),
|
|||
|
// ErrorMessageResourceName = "RequiredMessage")]
|
|||
|
[StringLength(50, ErrorMessageResourceType=typeof(Resource),
|
|||
|
ErrorMessageResourceName = "FabNameMaxLength")]
|
|||
|
public string Name { get; set; }
|
|||
|
|
|||
|
[Display(Name = "FabPhone", ResourceType = typeof(Resource))]
|
|||
|
//[Required(ErrorMessageResourceType = typeof(Resource),
|
|||
|
// ErrorMessageResourceName = "RequiredMessage")]
|
|||
|
[StringLength(30, ErrorMessageResourceType = typeof(Resource),
|
|||
|
ErrorMessageResourceName = "FabPhoneMaxLength")]
|
|||
|
public string Phone { get; set; }
|
|||
|
|
|||
|
[Display(Name="WorkerNumber",ResourceType=typeof(Resource))]
|
|||
|
public int? WorkerNumber { get; set; }
|
|||
|
|
|||
|
[Display(Name = "FabAddress", ResourceType = typeof(Resource))]
|
|||
|
//[Required(ErrorMessageResourceType = typeof(Resource),
|
|||
|
// ErrorMessageResourceName = "RequiredMessage")]
|
|||
|
[StringLength(300, ErrorMessageResourceType = typeof(Resource),
|
|||
|
ErrorMessageResourceName = "FabAddressMaxLength")]
|
|||
|
public string Address { get; set; }
|
|||
|
|
|||
|
[Display(Name = "IsIso14064Passed", ResourceType = typeof(Resource))]
|
|||
|
//[Required(ErrorMessageResourceType = typeof(Resource),
|
|||
|
// ErrorMessageResourceName = "RequiredMessage")]
|
|||
|
public bool IsIso14064Passed { get; set; }
|
|||
|
|
|||
|
public bool ISO14064TUV { get; set; }
|
|||
|
|
|||
|
public bool ISO14064DNV { get; set; }
|
|||
|
|
|||
|
public bool ISO14064BV { get; set; }
|
|||
|
|
|||
|
public bool ISO14064SGS { get; set; }
|
|||
|
|
|||
|
public bool ISO14064BSI { get; set; }
|
|||
|
|
|||
|
public bool ISO14064UL { get; set; }
|
|||
|
|
|||
|
public bool ISO14064Other { get; set; }
|
|||
|
|
|||
|
public string ISO14064OtherString { get; set; }
|
|||
|
|
|||
|
public decimal ISO14064Gas { get; set; }
|
|||
|
|
|||
|
public int ISO14064PassedYear { get; set; }
|
|||
|
|
|||
|
[InverseProperty("TargetFab")]
|
|||
|
[JsonIgnore][IgnoreDataMember]
|
|||
|
public virtual ICollection<OrganizationLCA> OrganizationLCAs { get; set; }
|
|||
|
|
|||
|
[InverseProperty("TargetFab")]
|
|||
|
[JsonIgnore][IgnoreDataMember]
|
|||
|
public virtual ICollection<ProductLCA> ProductLCAs { get; set; }
|
|||
|
|
|||
|
public int CompanyID { get; set; }
|
|||
|
|
|||
|
[ForeignKey("CompanyID")]
|
|||
|
[JsonIgnore][IgnoreDataMember]
|
|||
|
public virtual NormalCompany OwnerCompany { get;private set; }
|
|||
|
|
|||
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|||
|
{
|
|||
|
var result = new List<ValidationResult>();
|
|||
|
if (string.IsNullOrWhiteSpace(Name))
|
|||
|
result.Add(new ValidationResult(Resource.RequiredMessage, new[] { nameof(Name) }));
|
|||
|
if (string.IsNullOrWhiteSpace(Phone))
|
|||
|
result.Add(new ValidationResult(Resource.RequiredMessage, new[] { nameof(Phone) }));
|
|||
|
if (string.IsNullOrWhiteSpace(Address))
|
|||
|
result.Add(new ValidationResult(Resource.RequiredMessage, new[] { nameof(Address) }));
|
|||
|
//if (string.IsNullOrWhiteSpace(IsIso14064Passed))
|
|||
|
// result.Add(new ValidationResult(Resource.RequiredMessage, new[] { nameof(IsIso14064Passed) }));
|
|||
|
return result;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|