@using System.Reflection @using Microsoft.AspNetCore.Mvc.Controllers @using Infrastructure.Web.Mvc @{ var scope = (Url.ActionContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.GetCustomAttribute()?.Scope; var props = ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForEdit && !pm.HideSurroundingHtml && !pm.IsComplexType && !pm.IsCollectionType); } @{ foreach (var prop in props) { if (scope != null && scope == ControllerScopeType.Organ && prop.PropertyName == "OrganId") { continue; } var templateName = prop.DataTypeName ?? prop.TemplateHint ?? (prop.ModelType == typeof(string) ? typeof(string).Name : null); @Html.Display(prop.PropertyName, templateName) } }