Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CertificateApiEditModel : IValidatableObject
- {
- [Required]
- public CertificateType? Type { get; set; }
- [Required]
- public CertificateRegionType? Region { get; set; }
- //[MustBeTrue]
- public bool SignedOff { get; set; }
- #region Customer details
- [Required]
- public CustomerDetailsWorkType? WorkType { get; set; }
- [RequiredIf("WorkType", CustomerDetailsWorkType.Commercial), StringLength(100)]
- public string BusinessName { get; set; }
- [RequiredIf("WorkType", CustomerDetailsWorkType.Commercial), StringLength(100)]
- public string ContactName { get; set; }
- [StringLength(20)]
- public string JobId { get; set; }
- [RequiredIf("WorkType", CustomerDetailsWorkType.Residential), StringLength(50)]
- public string FirstName { get; set; }
- [RequiredIf("WorkType", CustomerDetailsWorkType.Residential), StringLength(50)]
- public string LastName { get; set; }
- [Required, StringLength(500)]
- public string BillingAddress { get; set; }
- [Required, StringLength(500)]
- public string SiteAddress { get; set; }
- #endregion
- [Required]
- public WorkerApiEditModel Worker { get; set; }
- [Required]
- public ContractorApiEditModel Contractor { get; set; }
- #region TestResults
- [Required]
- public DateTime? TestDate { get; set; }
- [Required]
- public List<CircuitResultApiEditModel> CircuitResults { get; set; }
- #endregion
- #region added by trinvh
- public InstrumentApiEditModel Instrument { get; set; }
- [Required]
- public CertificateBussinessType BussinessType { get; set; }
- [Required]
- public List<BoardApiEditModel> Boards { get; set; }
- #endregion
- public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
- {
- var result = new List<ValidationResult>();
- if (CircuitResults != null && CircuitResults.Count == 0)
- {
- result.Add(new ValidationResult("At least one circut result must be added."));
- }
- return result;
- }
- }
- public class BoardApiEditModel
- {
- public bool IsMainboard { get; set; }
- public bool IsNew { get; set; }
- public bool IsMen { get; set; }
- [StringLength(50)]
- public string Location { get; set; }
- [StringLength(50)]
- public string Designation { get; set; }
- [StringLength(50)]
- public string SupplyVia { get; set; }
- public int NumOfPhases { get; set; }
- public float Rating { get; set; }
- public float PfcAtBoard { get; set; }
- public float NominalVoltage { get; set; }
- public float EarthContinuity { get; set; }
- public float Bonding { get; set; }
- [Required]
- public List<CircuitResultApiEditModel> CircuitResults { get; set; }
- }
- public class TestResultApiEditModel
- {
- [StringLength(50)]
- public string Name { get; set; }
- [StringLength(50)]
- public string Value { get; set; }
- public TestResultType Type { get; set; }
- }
- public class InstrumentApiEditModel
- {
- [StringLength(50)]
- public string Model { get; set; }
- [StringLength(100)]
- public string SerialNumber { get; set; }
- }
- public class CircuitResultApiEditModel : IValidatableObject
- {
- [Required, StringLength(50)]
- public string Name { get; set; }
- [StringLength(50)]
- public string EarthContinuity { get; set; }
- [StringLength(50)]
- public string Bonding { get; set; }
- [StringLength(50)]
- public string Polarity { get; set; }
- [StringLength(50)]
- public string InsulationResistance { get; set; }
- [StringLength(50)]
- public string FaultLoopImpedance { get; set; }
- [StringLength(4000)]
- public string Notes { get; set; }
- #region Added by trinvh
- public CircuitPhaseType Phase { get; set; }
- public string WiringType { get; set; }
- public float NumOfPoints { get; set; }
- public float CableActiveSize { get; set; }
- public float CableEarthSize { get; set; }
- public float Rating { get; set; }
- [StringLength(50)]
- public string Type { get; set; }
- public float ShortCapacity { get; set; }
- public float RCDOperationCurrent { get; set; }
- public List<TestResultApiEditModel> TestResults { get; set; }
- #endregion
- public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
- {
- var result = new List<ValidationResult>();
- if (String.IsNullOrEmpty(EarthContinuity) && String.IsNullOrEmpty(Bonding) && String.IsNullOrEmpty(Polarity) && String.IsNullOrEmpty(InsulationResistance) && String.IsNullOrEmpty(FaultLoopImpedance))
- {
- result.Add(new ValidationResult("At least one test must be included in a circuit test result."));
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement