public async Task ValidateClinicalDetailsYearComparison_ReturnsErrorIfNewYearEarlierThanExisting() { // Arrange var initialPage = await Client.GetAsync(GetCurrentPathForId(Utilities.NOTIFIED_ID)); var initialDocument = await GetDocumentAsync(initialPage); var existingYear = 1990; var request = new YearComparisonValidationModel { NewYear = 1960, ExistingYear = existingYear, PropertyName = "BCG vaccination year" }; // Act var response = await Client.SendVerificationPostAsync( initialPage, initialDocument, GetHandlerPath(null, "ValidateClinicalDetailsYearComparison", Utilities.NOTIFIED_ID), request); // Assert var result = await response.Content.ReadAsStringAsync(); Assert.Equal("BCG vaccination year should be later than birth year (1990)", result); }
public ContentResult OnPostValidateClinicalDetailsYearComparison([FromBody] YearComparisonValidationModel validationData) { return(validationData.NewYear.HasValue ? ValidationService.GetYearComparisonValidationResult(validationData.NewYear.Value, validationData.ExistingYear, validationData.PropertyName) : Content("")); }