protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value == null) { return(ValidationResult.Success); } int valueNumber = -1; try { valueNumber = Int32.Parse(value.ToString()); } catch (Exception) { return(new ValidationResult("Property is invalid")); } if (valueNumber < 0) { return(new ValidationResult("Property is invalid")); } using (CommonReferenceDataRepository db = new CommonReferenceDataRepository()) { var clientGroup = db.GetAssetTypes().SingleOrDefault(s => s.AssetTypeID == valueNumber); if (clientGroup != null) { return(ValidationResult.Success); } else { return(new ValidationResult(ErrorMessage)); } } }
public void CanGenerateFilteredCommissionsAndFees() { CommonReferenceDataRepository repo = new CommonReferenceDataRepository(null); var fees = repo.GetCommissionAndFees_Filtered(c => c.CommissionsAndFeesId == 1); Assert.AreEqual(1, fees.Count); }
public void EnumCanProduceItems() { CommonReferenceDataRepository repo = new CommonReferenceDataRepository(null); var professionTypes = repo.GetAllProfessionTypes(); Assert.AreEqual(7, professionTypes.Count); }
public EducationLevelController() { repo = new CommonReferenceDataRepository(); }