Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. public class CertificateApiEditModel : IValidatableObject
  2. {
  3. [Required]
  4. public CertificateType? Type { get; set; }
  5.  
  6. [Required]
  7. public CertificateRegionType? Region { get; set; }
  8.  
  9. //[MustBeTrue]
  10. public bool SignedOff { get; set; }
  11.  
  12.  
  13. #region Customer details
  14.  
  15. [Required]
  16. public CustomerDetailsWorkType? WorkType { get; set; }
  17.  
  18. [RequiredIf("WorkType", CustomerDetailsWorkType.Commercial), StringLength(100)]
  19. public string BusinessName { get; set; }
  20.  
  21. [RequiredIf("WorkType", CustomerDetailsWorkType.Commercial), StringLength(100)]
  22. public string ContactName { get; set; }
  23.  
  24. [StringLength(20)]
  25. public string JobId { get; set; }
  26.  
  27. [RequiredIf("WorkType", CustomerDetailsWorkType.Residential), StringLength(50)]
  28. public string FirstName { get; set; }
  29.  
  30. [RequiredIf("WorkType", CustomerDetailsWorkType.Residential), StringLength(50)]
  31. public string LastName { get; set; }
  32.  
  33. [Required, StringLength(500)]
  34. public string BillingAddress { get; set; }
  35.  
  36. [Required, StringLength(500)]
  37. public string SiteAddress { get; set; }
  38.  
  39. #endregion
  40.  
  41. [Required]
  42. public WorkerApiEditModel Worker { get; set; }
  43.  
  44. [Required]
  45. public ContractorApiEditModel Contractor { get; set; }
  46.  
  47.  
  48. #region TestResults
  49.  
  50. [Required]
  51. public DateTime? TestDate { get; set; }
  52.  
  53. [Required]
  54. public List<CircuitResultApiEditModel> CircuitResults { get; set; }
  55. #endregion
  56.  
  57. #region added by trinvh
  58. public InstrumentApiEditModel Instrument { get; set; }
  59. [Required]
  60. public CertificateBussinessType BussinessType { get; set; }
  61. [Required]
  62. public List<BoardApiEditModel> Boards { get; set; }
  63. #endregion
  64.  
  65. public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
  66. {
  67. var result = new List<ValidationResult>();
  68.  
  69. if (CircuitResults != null && CircuitResults.Count == 0)
  70. {
  71. result.Add(new ValidationResult("At least one circut result must be added."));
  72. }
  73.  
  74. return result;
  75. }
  76. }
  77.  
  78. public class BoardApiEditModel
  79. {
  80. public bool IsMainboard { get; set; }
  81. public bool IsNew { get; set; }
  82. public bool IsMen { get; set; }
  83.  
  84. [StringLength(50)]
  85. public string Location { get; set; }
  86. [StringLength(50)]
  87. public string Designation { get; set; }
  88. [StringLength(50)]
  89. public string SupplyVia { get; set; }
  90.  
  91. public int NumOfPhases { get; set; }
  92. public float Rating { get; set; }
  93. public float PfcAtBoard { get; set; }
  94. public float NominalVoltage { get; set; }
  95. public float EarthContinuity { get; set; }
  96. public float Bonding { get; set; }
  97. [Required]
  98. public List<CircuitResultApiEditModel> CircuitResults { get; set; }
  99. }
  100.  
  101. public class TestResultApiEditModel
  102. {
  103. [StringLength(50)]
  104. public string Name { get; set; }
  105. [StringLength(50)]
  106. public string Value { get; set; }
  107.  
  108. public TestResultType Type { get; set; }
  109. }
  110.  
  111. public class InstrumentApiEditModel
  112. {
  113. [StringLength(50)]
  114. public string Model { get; set; }
  115. [StringLength(100)]
  116. public string SerialNumber { get; set; }
  117. }
  118.  
  119. public class CircuitResultApiEditModel : IValidatableObject
  120. {
  121. [Required, StringLength(50)]
  122. public string Name { get; set; }
  123.  
  124. [StringLength(50)]
  125. public string EarthContinuity { get; set; }
  126.  
  127. [StringLength(50)]
  128. public string Bonding { get; set; }
  129.  
  130. [StringLength(50)]
  131. public string Polarity { get; set; }
  132.  
  133. [StringLength(50)]
  134. public string InsulationResistance { get; set; }
  135.  
  136. [StringLength(50)]
  137. public string FaultLoopImpedance { get; set; }
  138.  
  139. [StringLength(4000)]
  140. public string Notes { get; set; }
  141.  
  142. #region Added by trinvh
  143. public CircuitPhaseType Phase { get; set; }
  144. public string WiringType { get; set; }
  145. public float NumOfPoints { get; set; }
  146. public float CableActiveSize { get; set; }
  147. public float CableEarthSize { get; set; }
  148. public float Rating { get; set; }
  149. [StringLength(50)]
  150. public string Type { get; set; }
  151.  
  152. public float ShortCapacity { get; set; }
  153. public float RCDOperationCurrent { get; set; }
  154.  
  155. public List<TestResultApiEditModel> TestResults { get; set; }
  156. #endregion
  157.  
  158.  
  159. public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
  160. {
  161. var result = new List<ValidationResult>();
  162.  
  163. if (String.IsNullOrEmpty(EarthContinuity) && String.IsNullOrEmpty(Bonding) && String.IsNullOrEmpty(Polarity) && String.IsNullOrEmpty(InsulationResistance) && String.IsNullOrEmpty(FaultLoopImpedance))
  164. {
  165. result.Add(new ValidationResult("At least one test must be included in a circuit test result."));
  166. }
  167.  
  168. return result;
  169. }
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement