public static ValidationResultViewModel GetValidationResultViewModel <TModel, TProperty>(this HtmlHelper <TModel> html, VacancyViewModel vacancyViewModel, Expression <Func <TModel, TProperty> > propertyExpression, ModelStateDictionary modelState, string viewWarningUrl, string comment) { var propertyName = ExpressionHelper.GetExpressionText(propertyExpression); var anchorName = propertyName.Replace(".", "_").ToLower(); var hasError = modelState.HasErrorsFor(propertyName); var error = modelState.ErrorMessageFor(propertyName); var hasWarning = modelState.HasWarningsFor(propertyName); var warning = modelState.WarningMessageFor(propertyName); viewWarningUrl = $"{viewWarningUrl}#{propertyName.Substring(propertyName.LastIndexOf(".", StringComparison.Ordinal) + 1).ToLower()}"; var validationResultViewModel = new ValidationResultViewModel(vacancyViewModel.Status, anchorName, hasError, error, hasWarning, warning, viewWarningUrl, comment); return(validationResultViewModel); }