using System; using System.Collections.Generic; using System.Linq; using System.Web; using Microsoft.AspNetCore.Mvc; using MySystem.BsModels; namespace MySystem { public class PageUpdateInfoDictionary { WebCMSEntities db = new WebCMSEntities(); #region 页面模板字典 public Dictionary getPageUpdateInfoDic(string Kind = "default") { List PageUpdateInfoList = db.PageUpdateInfo.Where(m => m.SeoKeyword == Kind).OrderBy(m => m.ModulePath).ToList(); Dictionary PageUpdateInfoDic = new Dictionary(); foreach (PageUpdateInfo subPageUpdateInfo in PageUpdateInfoList) { PageUpdateInfoDic.Add(subPageUpdateInfo.ModulePath.Replace(".html", ""), subPageUpdateInfo.Title+subPageUpdateInfo.ModulePath.Replace(".html", "")); } return PageUpdateInfoDic; } #endregion #region 根据字典key获取字典值 public string getDictionaryNameByKey(Dictionary data, string key) { if (data.ContainsKey(key)) { return data[key]; } return ""; } public string getDictionaryNameById(Dictionary data, int key) { if (data.ContainsKey(key)) { return data[key]; } return ""; } public string getDictionaryNamesByKeys(Dictionary data, string keys) { string result = ""; string[] keylist = keys.Split(','); foreach (string subkey in keylist) { if (data.ContainsKey(subkey)) { result += data[subkey] + ","; } } return result.TrimEnd(','); } #endregion } }