LotteryCache.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using CB.Cache;
  4. using CB.Entity;
  5. namespace CB.Data
  6. {
  7. public partial class Caches
  8. {
  9. /// <summary>
  10. /// 彩种列表
  11. /// </summary>
  12. /// <returns></returns>
  13. public static IList<LotteryInfo> GetLotteryList()
  14. {
  15. var cache = CBCache.GetCacheService();
  16. IList<LotteryInfo> list = cache.GetObject(CacheKeys.LotteryList) as IList<LotteryInfo>;
  17. if (null == list)
  18. {
  19. list = LotteryService.ToList();
  20. cache.AddObject(CacheKeys.LotteryList, list);
  21. }
  22. return list;
  23. }
  24. /// <summary>
  25. /// 根据区域aid获取所属区域的彩种
  26. /// </summary>
  27. /// <param name="aid"></param>
  28. /// <returns></returns>
  29. public static IList<LotteryInfo> GetLotteryList(int aid)
  30. {
  31. var list = GetLotteryList();
  32. if (null == list || 0 >= list.Count)
  33. return null;
  34. IList<LotteryInfo> rlist = new List<LotteryInfo>();
  35. foreach (var item in list)
  36. {
  37. if (aid == item.Aid)
  38. rlist.Add(item);
  39. }
  40. return rlist;
  41. }
  42. /// <summary>
  43. /// 获取彩种详细
  44. /// </summary>
  45. /// <param name="aid"></param>
  46. /// <returns></returns>
  47. public static LotteryInfo GetLotteryInfo(int cid)
  48. {
  49. var list = GetLotteryList();
  50. if (null == list || 0 >= list.Count)
  51. return null;
  52. LotteryInfo entity = null;
  53. foreach (var item in list)
  54. {
  55. if (cid == item.Cid)
  56. {
  57. entity = item; break;
  58. }
  59. }
  60. return entity;
  61. }
  62. }
  63. }