AppendixService.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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.Appendix;
  8. using GreenTree.Nachtragsmanagement.Core.Domain.Invoice;
  9. namespace GreenTree.Nachtragsmanagement.Services.Appendix
  10. {
  11. public class AppendixService : IAppendixService
  12. {
  13. #region Fields
  14. private readonly IRepository<Core.Domain.Appendix.Appendix> _appendixRepository;
  15. private readonly IRepository<Category> _categoryRepository;
  16. private readonly IRepository<Invoice> _invoiceRepository;
  17. private readonly IRepository<State> _stateRepository;
  18. #endregion
  19. #region Ctor
  20. /// <summary>
  21. /// Initializes a new instance of the AppendixService class
  22. /// </summary>
  23. public AppendixService(
  24. IRepository<Core.Domain.Appendix.Appendix> appendixRepository,
  25. IRepository<Category> categoryRepository,
  26. IRepository<Invoice> invoiceRepository,
  27. IRepository<State> stateRepository)
  28. {
  29. _appendixRepository = appendixRepository;
  30. _categoryRepository = categoryRepository;
  31. _invoiceRepository = invoiceRepository;
  32. _stateRepository = stateRepository;
  33. }
  34. #endregion
  35. #region Appendix
  36. /// <summary>
  37. /// Gets all appendices
  38. /// </summary>
  39. public IList<Core.Domain.Appendix.Appendix> GetAllAppendices()
  40. {
  41. return _appendixRepository.Table.ToList();
  42. }
  43. /// <summary>
  44. /// Gets a appendix by specified Id
  45. /// </summary>
  46. /// <param name="id">Appendix identifier.</param>
  47. public Core.Domain.Appendix.Appendix GetAppendixById(int id)
  48. {
  49. return _appendixRepository.GetById(id);
  50. }
  51. /// <summary>
  52. /// Gets all appendices to the specified ids
  53. /// </summary>
  54. public IList<Core.Domain.Appendix.Appendix> GetAppendicesByIds(int[] ids)
  55. {
  56. return _appendixRepository.Table
  57. .Where(u => ids.Contains(u.Id))
  58. .ToList();
  59. }
  60. /// <summary>
  61. /// Gets a appendix by specified custom number
  62. /// </summary>
  63. /// <param name="customNumber">Customer number.</param>
  64. public Core.Domain.Appendix.Appendix GetAppendixByCustomNumber(string customNumber)
  65. {
  66. return _appendixRepository
  67. .Table.FirstOrDefault(u => u.CustomNumber == customNumber);
  68. }
  69. /// <summary>
  70. /// Insert a appendix
  71. /// </summary>
  72. /// <param name="appendix">Appendix.</param>
  73. public void InsertAppendix(Core.Domain.Appendix.Appendix appendix)
  74. {
  75. _appendixRepository.Insert(appendix);
  76. }
  77. /// <summary>
  78. /// Update a appendix
  79. /// </summary>
  80. /// <param name="appendix">Appendix.</param>
  81. public void UpdateAppendix(Core.Domain.Appendix.Appendix appendix)
  82. {
  83. _appendixRepository.Update(appendix);
  84. }
  85. /// <summary>
  86. /// Delete a appendix
  87. /// </summary>
  88. /// <param name="appendix">Appendix.</param>
  89. public void DeleteAppendix(Core.Domain.Appendix.Appendix appendix)
  90. {
  91. _appendixRepository.Delete(appendix);
  92. }
  93. #endregion
  94. #region Category
  95. /// <summary>
  96. /// Gets all categories
  97. /// </summary>
  98. public IList<Category> GetAllCategories()
  99. {
  100. return _categoryRepository.Table.ToList();
  101. }
  102. /// <summary>
  103. /// Gets a category by specified Id
  104. /// </summary>
  105. /// <param name="id">Category identifier.</param>
  106. public Category GetCategoryById(int id)
  107. {
  108. return _categoryRepository.GetById(id);
  109. }
  110. /// <summary>
  111. /// Gets all categories to the specified ids
  112. /// </summary>
  113. public IList<Category> GetCategoriesByIds(int[] ids)
  114. {
  115. return _categoryRepository.Table
  116. .Where(r => ids.Contains(r.Id))
  117. .ToList();
  118. }
  119. /// <summary>
  120. /// Insert a appendix
  121. /// </summary>
  122. /// <param name="category">Category.</param>
  123. public void InsertCategory(Category category)
  124. {
  125. _categoryRepository.Insert(category);
  126. }
  127. /// <summary>
  128. /// Update a category
  129. /// </summary>
  130. /// <param name="category">Category.</param>
  131. public void UpdateCategory(Category category)
  132. {
  133. _categoryRepository.Update(category);
  134. }
  135. /// <summary>
  136. /// Delete a category
  137. /// </summary>
  138. /// <param name="category">Category.</param>
  139. public void DeleteCategory(Category category)
  140. {
  141. _categoryRepository.Delete(category);
  142. }
  143. #endregion
  144. #region Invoice
  145. /// <summary>
  146. /// Gets all invoices
  147. /// </summary>
  148. public IList<Invoice> GetAllInvoices()
  149. {
  150. return _invoiceRepository.Table.ToList();
  151. }
  152. /// <summary>
  153. /// Gets a invoice by specified Id
  154. /// </summary>
  155. /// <param name="id">Invoice identifier.</param>
  156. public Invoice GetInvoiceById(int id)
  157. {
  158. return _invoiceRepository.GetById(id);
  159. }
  160. /// <summary>
  161. /// Gets all invoices to the specified ids
  162. /// </summary>
  163. public IList<Invoice> GetInvoicesByIds(int[] ids)
  164. {
  165. return _invoiceRepository.Table
  166. .Where(r => ids.Contains(r.Id))
  167. .ToList();
  168. }
  169. /// <summary>
  170. /// Insert a appendix
  171. /// </summary>
  172. /// <param name="invoice">Invoice.</param>
  173. public void InsertInvoice(Invoice invoice)
  174. {
  175. _invoiceRepository.Insert(invoice);
  176. }
  177. /// <summary>
  178. /// Update a invoice
  179. /// </summary>
  180. /// <param name="invoice">Invoice.</param>
  181. public void UpdateInvoice(Invoice invoice)
  182. {
  183. _invoiceRepository.Update(invoice);
  184. }
  185. /// <summary>
  186. /// Delete a invoice
  187. /// </summary>
  188. /// <param name="invoice">Invoice.</param>
  189. public void DeleteInvoice(Invoice invoice)
  190. {
  191. _invoiceRepository.Delete(invoice);
  192. }
  193. #endregion
  194. #region State
  195. /// <summary>
  196. /// Gets all states
  197. /// </summary>
  198. public IList<State> GetAllStates()
  199. {
  200. return _stateRepository.Table.ToList();
  201. }
  202. /// <summary>
  203. /// Gets a state by specified Id
  204. /// </summary>
  205. /// <param name="id">State identifier.</param>
  206. public State GetStateById(int id)
  207. {
  208. return _stateRepository.GetById(id);
  209. }
  210. /// <summary>
  211. /// Gets all states to the specified ids
  212. /// </summary>
  213. public IList<State> GetStatesByIds(int[] ids)
  214. {
  215. return _stateRepository.Table
  216. .Where(r => ids.Contains(r.Id))
  217. .ToList();
  218. }
  219. /// <summary>
  220. /// Insert a appendix
  221. /// </summary>
  222. /// <param name="state">State.</param>
  223. public void InsertState(State state)
  224. {
  225. _stateRepository.Insert(state);
  226. }
  227. /// <summary>
  228. /// Update a state
  229. /// </summary>
  230. /// <param name="state">State.</param>
  231. public void UpdateState(State state)
  232. {
  233. _stateRepository.Update(state);
  234. }
  235. /// <summary>
  236. /// Delete a state
  237. /// </summary>
  238. /// <param name="state">State.</param>
  239. public void DeleteState(State state)
  240. {
  241. _stateRepository.Delete(state);
  242. }
  243. #endregion
  244. }
  245. }