SysFunctionRepository.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using YZXYH.Repository.Models;
  6. namespace YZXYH.Repository
  7. {
  8. public partial class SysFunctionRepository
  9. {
  10. //public string GetFatherInfo()
  11. //{
  12. // StringBuilder sb = new StringBuilder();
  13. // for (int i = 0; i <= 3; i++)
  14. // {
  15. // var j = i;
  16. // List<SysFunction> sysFunctions = Get(a=>a.Depth==j,a => a.OrderBy(s => s.Sort)).ToList();
  17. // foreach (var sysFunction in sysFunctions)
  18. // {
  19. // sb.Append("<option value=\"" + sysFunction.Id + "\">" + sysFunction.FunctionName + "</option>");
  20. // }
  21. // }
  22. // return sb.ToString();
  23. //}
  24. public string GetFatherInfo(string id)
  25. {
  26. StringBuilder sb = new StringBuilder();
  27. string fatherId = GetSingle(a => a.Id == id)?.FatherID ?? "";
  28. for (int i = 0; i <= 3; i++)
  29. {
  30. var j = i;
  31. List<SysFunction> sysFunctions = Get(a => a.Depth == j, a => a.OrderBy(s => s.Sort)).ToList();
  32. foreach (var sysFunction in sysFunctions)
  33. {
  34. if (sysFunction.Id==fatherId)
  35. {
  36. sb.Append("<option value=\"" + sysFunction.Id + "\" selected=\"selected\">" + sysFunction.FunctionName + "</option>");
  37. }
  38. else
  39. {
  40. sb.Append("<option value=\"" + sysFunction.Id + "\">" + sysFunction.FunctionName + "</option>");
  41. }
  42. }
  43. }
  44. return sb.ToString();
  45. }
  46. }
  47. }