/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (FarmId != null) { hashCode = hashCode * 59 + FarmId.GetHashCode(); } if (Date != null) { hashCode = hashCode * 59 + Date.GetHashCode(); } if (Plant != null) { hashCode = hashCode * 59 + Plant.GetHashCode(); } if (GrowthStage != null) { hashCode = hashCode * 59 + GrowthStage.GetHashCode(); } if (Answer != null) { hashCode = hashCode * 59 + Answer.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if RqGuidelines instances are equal /// </summary> /// <param name="other">Instance of RqGuidelines to be compared</param> /// <returns>Boolean</returns> public bool Equals(RqGuidelines other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( FarmId == other.FarmId || FarmId != null && FarmId.Equals(other.FarmId) ) && ( Plant == other.Plant || Plant != null && Plant.Equals(other.Plant) ) && ( Date == other.Date || Date != null && Date.Equals(other.Date) ) && ( Disaster == other.Disaster || Disaster != null && Disaster.Equals(other.Disaster) )); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (RegionId != null) { hashCode = hashCode * 59 + RegionId.GetHashCode(); } if (RegionNm != null) { hashCode = hashCode * 59 + RegionNm.GetHashCode(); } if (FarmId != null) { hashCode = hashCode * 59 + FarmId.GetHashCode(); } if (Plant != null) { hashCode = hashCode * 59 + Plant.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if InitData instances are equal /// </summary> /// <param name="other">Instance of InitData to be compared</param> /// <returns>Boolean</returns> public bool Equals(InitData other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( RegionId == other.RegionId || RegionId != null && RegionId.Equals(other.RegionId) ) && ( RegionNm == other.RegionNm || RegionNm != null && RegionNm.Equals(other.RegionNm) ) && ( FarmId == other.FarmId || FarmId != null && FarmId.Equals(other.FarmId) ) && ( Plant == other.Plant || Plant != null && Plant.SequenceEqual(other.Plant) )); }
/// <summary> /// Returns true if SendSurveyData instances are equal /// </summary> /// <param name="other">Instance of SendSurveyData to be compared</param> /// <returns>Boolean</returns> public bool Equals(SendSurveyData other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( FarmId == other.FarmId || FarmId != null && FarmId.Equals(other.FarmId) ) && ( Date == other.Date || Date != null && Date.Equals(other.Date) ) && ( Plant == other.Plant || Plant != null && Plant.Equals(other.Plant) ) && ( GrowthStage == other.GrowthStage || GrowthStage != null && GrowthStage.Equals(other.GrowthStage) ) && ( Answer == other.Answer || Answer != null && Answer.SequenceEqual(other.Answer) )); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { OECContext _context = OEC_Singleton.Context(); FarmId = Convert.ToInt32(FarmId.ToString().Trim()); if (Name != null) { Name = Name.Trim(); Name = HKValidations.HKCapitalize(Name); } if (Address != null) { Address = Address.Trim(); Address = HKValidations.HKCapitalize(Address); } if (Town != null) { Town = Town.Trim(); Town = HKValidations.HKCapitalize(Town); } if (County != null) { County = County.Trim(); County = HKValidations.HKCapitalize(County); } if (ProvinceCode != null) { ProvinceCode = ProvinceCode.Trim(); ProvinceCode = ProvinceCode.ToUpper(); } if (PostalCode != null) { PostalCode = PostalCode.Trim(); } if (HomePhone != null) { HomePhone = HomePhone.Trim(); } if (CellPhone != null) { CellPhone = CellPhone.Trim(); } if (Email != null) { Email = Email.Trim(); } if (Directions != null) { Directions = Directions.Trim(); } if (String.IsNullOrWhiteSpace(Name) || String.IsNullOrWhiteSpace(ProvinceCode)) { if (String.IsNullOrWhiteSpace(Name)) { yield return(new ValidationResult("Name is required", new[] { "Name" })); } if (String.IsNullOrWhiteSpace(ProvinceCode)) { yield return(new ValidationResult("Province Code is required", new[] { "ProvinceCode" })); } } if (String.IsNullOrWhiteSpace(Town) && String.IsNullOrWhiteSpace(County)) { yield return(new ValidationResult("Either the town or county must be provided.", new[] { "Town", "County" })); } if (String.IsNullOrWhiteSpace(Email)) { if (string.IsNullOrWhiteSpace(Address)) { yield return(new ValidationResult("Address must be provided.", new[] { "Address" })); } if (string.IsNullOrWhiteSpace(PostalCode)) { yield return(new ValidationResult("Postal Code must be provided.", new[] { "PostalCode" })); } } if (!String.IsNullOrEmpty(PostalCode) && !String.IsNullOrWhiteSpace(ProvinceCode)) { string countryCode = ""; if (ProvinceCode.Length == 2) { countryCode = _context.Province.SingleOrDefault(p => p.ProvinceCode == ProvinceCode).CountryCode; } else { countryCode = _context.Province.SingleOrDefault(p => p.Name == ProvinceCode).CountryCode; } if (countryCode == "CA") { string pCode = PostalCode; if (!HKValidations.HKPostalCodeValidation(ref pCode)) { yield return(new ValidationResult("Please enter valid postal code.", new[] { "PostalCode" })); } PostalCode = pCode; } else if (countryCode == "US") { string zCode = PostalCode; if (!HKValidations.HKZipCodeValidation(ref zCode)) { yield return(new ValidationResult("Please enter valid zip code.", new[] { "PostalCode" })); } PostalCode = zCode; } } if (String.IsNullOrWhiteSpace(HomePhone) && String.IsNullOrWhiteSpace(CellPhone)) { yield return(new ValidationResult("Either the home phone number or cell phone number must be provided.", new[] { "HomePhone", "CellPhone" })); } else { if (!String.IsNullOrWhiteSpace(HomePhone)) { string hPhone = HomePhone; if (!HKValidations.HKPhoneNumberValidation(ref hPhone)) { yield return(new ValidationResult("Home phone number must be 10 digits only.", new[] { "HomePhone" })); } HomePhone = hPhone; } if (!String.IsNullOrWhiteSpace(CellPhone)) { string cPhone = CellPhone; if (!HKValidations.HKPhoneNumberValidation(ref cPhone)) { yield return(new ValidationResult("Cell phone number must be 10 digits only.", new[] { "CellPhone" })); } HomePhone = cPhone; } } yield return(ValidationResult.Success); }