@using System.Reflection @using Microsoft.AspNetCore.Mvc.Controllers @using Infrastructure.Web.Mvc @using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata @{ var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute()?.Scope; var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit).ToList(); } @foreach (var prop in props) { var uihit = prop.TemplateHint ?? prop.DataTypeName; var name = "query." + prop.PropertyName; if (scope != null && scope == ControllerScopeType.Organ && prop.PropertyName == "OrganId") { Html.Hidden(prop.PropertyName); continue; } if ((prop as DefaultModelMetadata).Attributes.Attributes.Any(o => o.GetType() == typeof(SkipSearchAttribute))) { continue; } if (prop.PropertyName == "Id" || prop.PropertyName == "Order" || prop.PropertyName == "Cron" || uihit == "ImageUrl" || uihit == "MultiSelectList" || uihit == "ImageUrl") { continue; } else { if (prop.IsNullableValueType && prop.UnderlyingOrModelType == typeof(bool)) { uihit = "SearchTemplates/Boolean.cshtml"; } if (uihit == "MultilineText") { uihit = "String"; }
@Html.Editor(prop.PropertyName, uihit, prop.AdditionalValues)
} }