PageUpdateInfoDictionary.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using Microsoft.AspNetCore.Mvc;
  6. using MySystem.BsModels;
  7. namespace MySystem
  8. {
  9. public class PageUpdateInfoDictionary
  10. {
  11. WebCMSEntities db = new WebCMSEntities();
  12. #region 页面模板字典
  13. public Dictionary<string, string> getPageUpdateInfoDic(string Kind = "default")
  14. {
  15. List<PageUpdateInfo> PageUpdateInfoList = db.PageUpdateInfo.Where(m => m.SeoKeyword == Kind).OrderBy(m => m.ModulePath).ToList();
  16. Dictionary<string, string> PageUpdateInfoDic = new Dictionary<string, string>();
  17. foreach (PageUpdateInfo subPageUpdateInfo in PageUpdateInfoList)
  18. {
  19. PageUpdateInfoDic.Add(subPageUpdateInfo.ModulePath.Replace(".html", ""), subPageUpdateInfo.Title+subPageUpdateInfo.ModulePath.Replace(".html", ""));
  20. }
  21. return PageUpdateInfoDic;
  22. }
  23. #endregion
  24. #region 根据字典key获取字典值
  25. public string getDictionaryNameByKey(Dictionary<string, string> data, string key)
  26. {
  27. if (data.ContainsKey(key))
  28. {
  29. return data[key];
  30. }
  31. return "";
  32. }
  33. public string getDictionaryNameById(Dictionary<int, string> data, int key)
  34. {
  35. if (data.ContainsKey(key))
  36. {
  37. return data[key];
  38. }
  39. return "";
  40. }
  41. public string getDictionaryNamesByKeys(Dictionary<string, string> data, string keys)
  42. {
  43. string result = "";
  44. string[] keylist = keys.Split(',');
  45. foreach (string subkey in keylist)
  46. {
  47. if (data.ContainsKey(subkey))
  48. {
  49. result += data[subkey] + ",";
  50. }
  51. }
  52. return result.TrimEnd(',');
  53. }
  54. #endregion
  55. }
  56. }