/// <summary> /// 地区下拉列表 /// </summary> /// <param name="htmlHelper">被扩展的htmlHelper实例</param> /// <param name="name">控件name属性</param> /// <param name="name">选中的地区编码</param> /// <param name="areaLevel">地区层级(默认取站点配置)</param> /// <param name="rootAreaCode">根级地区(默认取站点地区配置)</param> public static MvcHtmlString AreaDropDownList(this HtmlHelper htmlHelper, string name, string value, int?areaLevel = null, string rootAreaCode = null) { string getChildAreasUrl = SiteUrls.Instance().GetChildAreas(); AreaServiceHelper areaServiceHelper = new AreaServiceHelper(); if (areaLevel == null) { IAreaSettingsManager areaSettingsManager = DIContainer.Resolve <IAreaSettingsManager>(); AreaSettings areaSettings = areaSettingsManager.Get(); areaLevel = areaSettings.AreaLevel; } return(htmlHelper.LinkageDropDownList <string>(name, value, string.Empty, areaLevel.Value, areaServiceHelper.GetRootAreaDictionary(rootAreaCode), areaServiceHelper.GetParentCode, areaServiceHelper.GetChildrenDictionary, getChildAreasUrl)); }
/// <summary> /// 地区下拉列表 /// </summary> /// <param name="htmlHelper">被扩展的htmlHelper实例</param> /// <param name="expression">选择实体中类别属性的lamda表达式</param> /// <param name="areaLevel">地区层级(默认取站点地区配置)</param> /// <param name="rootAreaCode">根级地区(默认取站点地区配置)</param> public static MvcHtmlString AreaDropDownListFor <TModel>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, string> > expression, int?areaLevel = null, string rootAreaCode = null) { string getChildAreasUrl = SiteUrls.Instance().GetChildAreas(); AreaServiceHelper areaServiceHelper = new AreaServiceHelper(); if (areaLevel == null) { AreaSettings areaSettings = DIContainer.Resolve <ISettingsManager <AreaSettings> >().Get(); areaLevel = areaSettings.AreaLevel; } return(htmlHelper.LinkageDropDownListFor <TModel, string>(expression, string.Empty, areaLevel.Value, areaServiceHelper.GetRootAreaDictionary(rootAreaCode), areaServiceHelper.GetParentCode, areaServiceHelper.GetChildrenDictionary, getChildAreasUrl)); }