MiscService.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using GreenTree.Nachtragsmanagement.Core.Data;
  7. using GreenTree.Nachtragsmanagement.Core.Domain.Misc;
  8. namespace GreenTree.Nachtragsmanagement.Services.Misc
  9. {
  10. public class MiscService : IMiscService
  11. {
  12. #region Fields
  13. private readonly IRepository<MailNotification> _mailNotificationRepository;
  14. private readonly IRepository<NotificationEvent> _notificationEventRepository;
  15. private readonly IRepository<NotificationEventType> _notificationEventTypeRepository;
  16. #endregion
  17. #region Ctor
  18. /// <summary>
  19. /// Initializes a new instance of the MiscService class
  20. /// </summary>
  21. public MiscService(
  22. IRepository<MailNotification> mailNotificationRepository,
  23. IRepository<NotificationEvent> notificationEventRepository,
  24. IRepository<NotificationEventType> notificationEventTypeRepository)
  25. {
  26. _mailNotificationRepository = mailNotificationRepository;
  27. _notificationEventRepository = notificationEventRepository;
  28. _notificationEventTypeRepository = notificationEventTypeRepository;
  29. }
  30. #endregion
  31. #region MailNotification
  32. /// <summary>
  33. /// Gets all mailNotifications
  34. /// </summary>
  35. public IList<MailNotification> GetAllMailNotifications()
  36. {
  37. return _mailNotificationRepository.Table.ToList();
  38. }
  39. /// <summary>
  40. /// Gets a mailNotification by specified Id
  41. /// </summary>
  42. /// <param name="id">MailNotification identifier.</param>
  43. public MailNotification GetMailNotificationById(int id)
  44. {
  45. return _mailNotificationRepository.GetById(id);
  46. }
  47. /// <summary>
  48. /// Gets all mailNotifications to the specified ids
  49. /// </summary>
  50. public IList<MailNotification> GetMailNotificationsByIds(int[] ids)
  51. {
  52. return _mailNotificationRepository.Table
  53. .Where(u => ids.Contains(u.Id))
  54. .ToList();
  55. }
  56. /// <summary>
  57. /// Insert a mailNotification
  58. /// </summary>
  59. /// <param name="mailNotification">MailNotification.</param>
  60. public void InsertMailNotification(MailNotification mailNotification)
  61. {
  62. _mailNotificationRepository.Insert(mailNotification);
  63. }
  64. /// <summary>
  65. /// Update a mailNotification
  66. /// </summary>
  67. /// <param name="mailNotification">MailNotification.</param>
  68. public void UpdateMailNotification(MailNotification mailNotification)
  69. {
  70. _mailNotificationRepository.Update(mailNotification);
  71. }
  72. /// <summary>
  73. /// Delete a mailNotification
  74. /// </summary>
  75. /// <param name="mailNotification">MailNotification.</param>
  76. public void DeleteMailNotification(MailNotification mailNotification)
  77. {
  78. _mailNotificationRepository.Delete(mailNotification);
  79. }
  80. #endregion
  81. #region NotificationEvent
  82. /// <summary>
  83. /// Gets all notificationEvents
  84. /// </summary>
  85. public IList<NotificationEvent> GetAllNotificationEvents()
  86. {
  87. return _notificationEventRepository.Table.ToList();
  88. }
  89. /// <summary>
  90. /// Gets a notificationEvent by specified Id
  91. /// </summary>
  92. /// <param name="id">NotificationEvent identifier.</param>
  93. public NotificationEvent GetNotificationEventById(int id)
  94. {
  95. return _notificationEventRepository.GetById(id);
  96. }
  97. /// <summary>
  98. /// Gets all notificationEvents to the specified ids
  99. /// </summary>
  100. public IList<NotificationEvent> GetNotificationEventsByIds(int[] ids)
  101. {
  102. return _notificationEventRepository.Table
  103. .Where(r => ids.Contains(r.Id))
  104. .ToList();
  105. }
  106. /// <summary>
  107. /// Insert a mailNotification
  108. /// </summary>
  109. /// <param name="notificationEvent">NotificationEvent.</param>
  110. public void InsertNotificationEvent(NotificationEvent notificationEvent)
  111. {
  112. _notificationEventRepository.Insert(notificationEvent);
  113. }
  114. /// <summary>
  115. /// Update a notificationEvent
  116. /// </summary>
  117. /// <param name="notificationEvent">NotificationEvent.</param>
  118. public void UpdateNotificationEvent(NotificationEvent notificationEvent)
  119. {
  120. _notificationEventRepository.Update(notificationEvent);
  121. }
  122. /// <summary>
  123. /// Delete a notificationEvent
  124. /// </summary>
  125. /// <param name="notificationEvent">NotificationEvent.</param>
  126. public void DeleteNotificationEvent(NotificationEvent notificationEvent)
  127. {
  128. _notificationEventRepository.Delete(notificationEvent);
  129. }
  130. #endregion
  131. #region NotificationEventType
  132. /// <summary>
  133. /// Gets all notificationEventTypes
  134. /// </summary>
  135. public IList<NotificationEventType> GetAllNotificationEventTypes()
  136. {
  137. return _notificationEventTypeRepository.Table.ToList();
  138. }
  139. /// <summary>
  140. /// Gets a notificationEventType by specified Id
  141. /// </summary>
  142. /// <param name="id">NotificationEventType identifier.</param>
  143. public NotificationEventType GetNotificationEventTypeById(int id)
  144. {
  145. return _notificationEventTypeRepository.GetById(id);
  146. }
  147. /// <summary>
  148. /// Gets all notificationEventTypes to the specified ids
  149. /// </summary>
  150. public IList<NotificationEventType> GetNotificationEventTypesByIds(int[] ids)
  151. {
  152. return _notificationEventTypeRepository.Table
  153. .Where(r => ids.Contains(r.Id))
  154. .ToList();
  155. }
  156. /// <summary>
  157. /// Insert a appendix
  158. /// </summary>
  159. /// <param name="notificationEventType">NotificationEventType.</param>
  160. public void InsertNotificationEventType(NotificationEventType notificationEventType)
  161. {
  162. _notificationEventTypeRepository.Insert(notificationEventType);
  163. }
  164. /// <summary>
  165. /// Update a notificationEventType
  166. /// </summary>
  167. /// <param name="notificationEventType">NotificationEventType.</param>
  168. public void UpdateNotificationEventType(NotificationEventType notificationEventType)
  169. {
  170. _notificationEventTypeRepository.Update(notificationEventType);
  171. }
  172. /// <summary>
  173. /// Delete a notificationEventType
  174. /// </summary>
  175. /// <param name="notificationEventType">NotificationEventType.</param>
  176. public void DeleteNotificationEventType(NotificationEventType notificationEventType)
  177. {
  178. _notificationEventTypeRepository.Delete(notificationEventType);
  179. }
  180. #endregion
  181. }
  182. }