public Dictionary <string, string> GetFormDisplayValues(DynamicForm formModel) { var displayValues = new Dictionary <string, string>(); var htmlHelper = _htmlHelperGeneratorService.HtmlHelper(formModel); var properties = ((CustomModelMetadata)htmlHelper.ViewData.ModelMetadata).PropertiesRuntime(formModel); var propertyModelExplorers = htmlHelper.ModelExplorerPropertiesRuntime(); foreach (var prop in htmlHelper.ViewData.ModelMetadata.Properties.Where(p => p.ShowForDisplay)) { if (prop.IsCollectionType) { var displayString = htmlHelper.Display(prop.PropertyName).Render(); displayValues.Add(prop.PropertyName, displayString); } else if (prop.ModelType == typeof(Boolean)) { var displayString = htmlHelper.Display(prop.PropertyName).Render(); displayValues.Add(prop.PropertyName, displayString); } else if (prop.ModelType == typeof(DateTime)) { var displayString = ((DateTime)formModel[prop.PropertyName]).ToString("O"); displayValues.Add(prop.PropertyName, displayString); } else { var displayString = htmlHelper.DisplayText(prop.PropertyName); displayValues.Add(prop.PropertyName, displayString); } } return(displayValues); }
public DynamicFormsController( IMapper mapper, IEmailService emailService, AppSettings appSettings, IHtmlHelperGeneratorService htmlHelperGeneratorService, ICookieService cookieService, IHostingEnvironment hostingEnvironment, IDynamicFormsPresentationService dynamicFormsPresentationService, IDynamicFormsApplicationServices dynamicFormsApplicationService) : base(mapper, emailService, appSettings) { Html = htmlHelperGeneratorService.HtmlHelper(""); _cookieService = cookieService; _hostingEnvironment = hostingEnvironment; _dynamicFormsPresentationService = dynamicFormsPresentationService; }