AppendixService.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. #endregion
  18. #region Ctor
  19. /// <summary>
  20. /// Initializes a new instance of the AppendixService class
  21. /// </summary>
  22. public AppendixService(
  23. IRepository<Core.Domain.Appendix.Appendix> appendixRepository,
  24. IRepository<Category> categoryRepository,
  25. IRepository<Invoice> invoiceRepository)
  26. {
  27. _appendixRepository = appendixRepository;
  28. _categoryRepository = categoryRepository;
  29. _invoiceRepository = invoiceRepository;
  30. }
  31. #endregion
  32. #region Appendix
  33. /// <summary>
  34. /// Gets all appendices
  35. /// </summary>
  36. public IList<Core.Domain.Appendix.Appendix> GetAllAppendices()
  37. {
  38. return _appendixRepository.Table.ToList();
  39. }
  40. /// <summary>
  41. /// Gets a appendix by specified Id
  42. /// </summary>
  43. /// <param name="id">Appendix identifier.</param>
  44. public Core.Domain.Appendix.Appendix GetAppendixById(int id)
  45. {
  46. return _appendixRepository.GetById(id);
  47. }
  48. /// <summary>
  49. /// Gets all appendices to the specified ids
  50. /// </summary>
  51. public IList<Core.Domain.Appendix.Appendix> GetAppendicesByIds(int[] ids)
  52. {
  53. return _appendixRepository.Table
  54. .Where(u => ids.Contains(u.Id))
  55. .ToList();
  56. }
  57. /// <summary>
  58. /// Gets a appendix by specified custom number
  59. /// </summary>
  60. /// <param name="id">Customer number.</param>
  61. public Core.Domain.Appendix.Appendix GetAppendixByCustomNumber(int customNumber)
  62. {
  63. return _appendixRepository
  64. .Table.FirstOrDefault(u => u.CustomNumber == customNumber);
  65. }
  66. /// <summary>
  67. /// Insert a appendix
  68. /// </summary>
  69. /// <param name="appendix">Appendix.</param>
  70. public void InsertAppendix(Core.Domain.Appendix.Appendix appendix)
  71. {
  72. _appendixRepository.Insert(appendix);
  73. }
  74. /// <summary>
  75. /// Update a appendix
  76. /// </summary>
  77. /// <param name="appendix">Appendix.</param>
  78. public void UpdateAppendix(Core.Domain.Appendix.Appendix appendix)
  79. {
  80. _appendixRepository.Update(appendix);
  81. }
  82. /// <summary>
  83. /// Delete a appendix
  84. /// </summary>
  85. /// <param name="appendix">Appendix.</param>
  86. public void DeleteAppendix(Core.Domain.Appendix.Appendix appendix)
  87. {
  88. _appendixRepository.Delete(appendix);
  89. }
  90. #endregion
  91. #region Category
  92. /// <summary>
  93. /// Gets all categories
  94. /// </summary>
  95. public IList<Category> GetAllCategories()
  96. {
  97. return _categoryRepository.Table.ToList();
  98. }
  99. /// <summary>
  100. /// Gets a category by specified Id
  101. /// </summary>
  102. /// <param name="id">Category identifier.</param>
  103. public Category GetCategoryById(int id)
  104. {
  105. return _categoryRepository.GetById(id);
  106. }
  107. /// <summary>
  108. /// Gets all categories to the specified ids
  109. /// </summary>
  110. public IList<Category> GetCategoriesByIds(int[] ids)
  111. {
  112. return _categoryRepository.Table
  113. .Where(r => ids.Contains(r.Id))
  114. .ToList();
  115. }
  116. /// <summary>
  117. /// Insert a appendix
  118. /// </summary>
  119. /// <param name="category">Category.</param>
  120. public void InsertCategory(Category category)
  121. {
  122. _categoryRepository.Insert(category);
  123. }
  124. /// <summary>
  125. /// Update a category
  126. /// </summary>
  127. /// <param name="category">Category.</param>
  128. public void UpdateCategory(Category category)
  129. {
  130. _categoryRepository.Update(category);
  131. }
  132. /// <summary>
  133. /// Delete a category
  134. /// </summary>
  135. /// <param name="category">Category.</param>
  136. public void DeleteCategory(Category category)
  137. {
  138. _categoryRepository.Delete(category);
  139. }
  140. #endregion
  141. #region Invoice
  142. /// <summary>
  143. /// Gets all invoices
  144. /// </summary>
  145. public IList<Invoice> GetAllInvoices()
  146. {
  147. return _invoiceRepository.Table.ToList();
  148. }
  149. /// <summary>
  150. /// Gets a invoice by specified Id
  151. /// </summary>
  152. /// <param name="id">Invoice identifier.</param>
  153. public Invoice GetInvoiceById(int id)
  154. {
  155. return _invoiceRepository.GetById(id);
  156. }
  157. /// <summary>
  158. /// Gets all invoices to the specified ids
  159. /// </summary>
  160. public IList<Invoice> GetInvoicesByIds(int[] ids)
  161. {
  162. return _invoiceRepository.Table
  163. .Where(r => ids.Contains(r.Id))
  164. .ToList();
  165. }
  166. /// <summary>
  167. /// Insert a appendix
  168. /// </summary>
  169. /// <param name="invoice">Invoice.</param>
  170. public void InsertInvoice(Invoice invoice)
  171. {
  172. _invoiceRepository.Insert(invoice);
  173. }
  174. /// <summary>
  175. /// Update a invoice
  176. /// </summary>
  177. /// <param name="invoice">Invoice.</param>
  178. public void UpdateInvoice(Invoice invoice)
  179. {
  180. _invoiceRepository.Update(invoice);
  181. }
  182. /// <summary>
  183. /// Delete a invoice
  184. /// </summary>
  185. /// <param name="invoice">Invoice.</param>
  186. public void DeleteInvoice(Invoice invoice)
  187. {
  188. _invoiceRepository.Delete(invoice);
  189. }
  190. #endregion
  191. }
  192. }