/application/iPow.Application.dj.Service/LinksAndTopCountService.cs

https://bitbucket.org/JPomichael/miaow
C# | 130 lines | 83 code | 12 blank | 35 comment | 22 complexity | 0db942b6839483e39f6a19207f483582 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using iPow.Infrastructure.Crosscutting.EntityToDto;
  5. namespace iPow.Application.dj.Service
  6. {
  7. public class LinksAndTopCountService : ILinksAndTopCountService
  8. {
  9. /// <summary>
  10. ///
  11. /// </summary>
  12. iPow.Domain.Repository.ILinkInfoRepository linkInfoRepository;
  13. /// <summary>
  14. ///
  15. /// </summary>
  16. iPow.Domain.Repository.ISightInfoRepository sightInfoRepository;
  17. /// <summary>
  18. ///
  19. /// </summary>
  20. iPow.Domain.Repository.ITourPlanRepository tourPlanRepository;
  21. /// <summary>
  22. ///
  23. /// </summary>
  24. iPow.Domain.Repository.IHotelPropertyInfoRepository hotelPropertyInfoRepository;
  25. /// <summary>
  26. /// Initializes a new instance of the <see cref="LinksAndTopCountService"/> class.
  27. /// </summary>
  28. public LinksAndTopCountService(iPow.Domain.Repository.ILinkInfoRepository linkInfo,
  29. iPow.Domain.Repository.ISightInfoRepository sightInfo,
  30. iPow.Domain.Repository.ITourPlanRepository tourPlan,
  31. iPow.Domain.Repository.IHotelPropertyInfoRepository hotelPropertyInfo
  32. )
  33. {
  34. if (linkInfo == null)
  35. {
  36. throw new ArgumentNullException("linkInfoRepository is null");
  37. }
  38. if (sightInfo == null)
  39. {
  40. throw new ArgumentNullException("sightInfoRepository is null");
  41. }
  42. if (tourPlan == null)
  43. {
  44. throw new ArgumentNullException("tourPlanRepository is null");
  45. }
  46. if (hotelPropertyInfo == null)
  47. {
  48. throw new ArgumentNullException("hotelPropertyInfoRepository is null");
  49. }
  50. linkInfoRepository = linkInfo;
  51. sightInfoRepository = sightInfo;
  52. tourPlanRepository = tourPlan;
  53. hotelPropertyInfoRepository = hotelPropertyInfo;
  54. }
  55. /// <summary>
  56. /// Gets the text link list.
  57. /// </summary>
  58. /// <returns></returns>
  59. public List<iPow.Domain.Dto.Sys_LinksInfoDto> GetTextLinkList()
  60. {
  61. var temp = (from e in linkInfoRepository.GetList()
  62. where e.IsDelete == 0 &&
  63. (e.LinksPath == "" ||
  64. e.LinksPath == null ||
  65. e.LinksName == null ||
  66. e.LinksName == "") &&
  67. e.ClassID == 3 &&
  68. e.IsTop == 1
  69. orderby e.AddTime descending
  70. select e
  71. ).ToList();
  72. return temp.ToDto().ToList();
  73. }
  74. /// <summary>
  75. /// Gets the img link list.
  76. /// </summary>
  77. /// <returns></returns>
  78. public List<iPow.Domain.Dto.Sys_LinksInfoDto> GetImgLinkList()
  79. {
  80. var temp = (from e in linkInfoRepository.GetList()
  81. where e.IsDelete == 0 &&
  82. e.LinksPath != "" &&
  83. e.LinksPath != null &&
  84. e.LinksName != null &&
  85. e.LinksName != "" &&
  86. e.ClassID == 3 &&
  87. e.IsTop == 1
  88. orderby e.AddTime descending
  89. select e
  90. ).ToList();
  91. return temp.ToDto().ToList();
  92. }
  93. /// <summary>
  94. /// Gets the sight count.
  95. /// </summary>
  96. /// <returns></returns>
  97. public int GetSightCount()
  98. {
  99. return sightInfoRepository.GetList().Count();
  100. }
  101. /// <summary>
  102. /// Gets the tour info count.
  103. /// </summary>
  104. /// <returns></returns>
  105. public int GetTourInfoCount()
  106. {
  107. return tourPlanRepository.GetList().Count();
  108. }
  109. /// <summary>
  110. /// Gets the hotel info count.
  111. /// </summary>
  112. /// <returns></returns>
  113. public int GetHotelInfoCount()
  114. {
  115. return hotelPropertyInfoRepository.GetList().Count();
  116. }
  117. }
  118. }