77 using Microsoft . EntityFrameworkCore . Internal ;
88 using Models ;
99 using OperatorInterfaces ;
10- using Shared . DomainDrivenDesign . EventStore ;
1110 using Shared . EventStore . EventStore ;
1211 using TransactionAggregate ;
1312
@@ -20,21 +19,21 @@ public class TransactionAggregateManager : ITransactionAggregateManager
2019 #region Fields
2120
2221 /// <summary>
23- /// The aggregate repository manager
22+ /// The transaction aggregate repository
2423 /// </summary>
25- private readonly IAggregateRepositoryManager AggregateRepositoryManager ;
24+ private readonly IAggregateRepository < TransactionAggregate > TransactionAggregateRepository ;
2625
2726 #endregion
2827
2928 #region Constructors
3029
3130 /// <summary>
32- /// Initializes a new instance of the <see cref="TransactionAggregateManager"/> class.
31+ /// Initializes a new instance of the <see cref="TransactionAggregateManager" /> class.
3332 /// </summary>
34- /// <param name="aggregateRepositoryManager ">The aggregate repository manager .</param>
35- public TransactionAggregateManager ( IAggregateRepositoryManager aggregateRepositoryManager )
33+ /// <param name="transactionAggregateRepository ">The transaction aggregate repository.</param>
34+ public TransactionAggregateManager ( IAggregateRepository < TransactionAggregate > transactionAggregateRepository )
3635 {
37- this . AggregateRepositoryManager = aggregateRepositoryManager ;
36+ this . TransactionAggregateRepository = transactionAggregateRepository ;
3837 }
3938
4039 #endregion
@@ -60,10 +59,7 @@ public async Task AuthoriseTransaction(Guid estateId,
6059 String responseMessage ,
6160 CancellationToken cancellationToken )
6261 {
63- IAggregateRepository < TransactionAggregate > transactionAggregateRepository =
64- this . AggregateRepositoryManager . GetAggregateRepository < TransactionAggregate > ( estateId ) ;
65-
66- TransactionAggregate transactionAggregate = await transactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
62+ TransactionAggregate transactionAggregate = await this . TransactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
6763
6864 transactionAggregate . AuthoriseTransaction ( operatorIdentifier ,
6965 operatorResponse . AuthorisationCode ,
@@ -73,7 +69,7 @@ public async Task AuthoriseTransaction(Guid estateId,
7369 ( ( Int32 ) transactionResponseCode ) . ToString ( ) . PadLeft ( 4 , '0' ) ,
7470 responseMessage ) ;
7571
76- await transactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
72+ await this . TransactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
7773 }
7874
7975 /// <summary>
@@ -90,16 +86,13 @@ public async Task AuthoriseTransactionLocally(Guid estateId,
9086 ( String responseMessage , TransactionResponseCode responseCode ) validationResult ,
9187 CancellationToken cancellationToken )
9288 {
93- IAggregateRepository < TransactionAggregate > transactionAggregateRepository =
94- this . AggregateRepositoryManager . GetAggregateRepository < TransactionAggregate > ( estateId ) ;
95-
96- TransactionAggregate transactionAggregate = await transactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
89+ TransactionAggregate transactionAggregate = await this . TransactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
9790
9891 transactionAggregate . AuthoriseTransactionLocally ( authorisationCode ,
9992 ( ( Int32 ) validationResult . responseCode ) . ToString ( ) . PadLeft ( 4 , '0' ) ,
10093 validationResult . responseMessage ) ;
10194
102- await transactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
95+ await this . TransactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
10396 }
10497
10598 /// <summary>
@@ -112,14 +105,11 @@ public async Task CompleteTransaction(Guid estateId,
112105 Guid transactionId ,
113106 CancellationToken cancellationToken )
114107 {
115- IAggregateRepository < TransactionAggregate > transactionAggregateRepository =
116- this . AggregateRepositoryManager . GetAggregateRepository < TransactionAggregate > ( estateId ) ;
117-
118- TransactionAggregate transactionAggregate = await transactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
108+ TransactionAggregate transactionAggregate = await this . TransactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
119109
120110 transactionAggregate . CompleteTransaction ( ) ;
121111
122- await transactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
112+ await this . TransactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
123113 }
124114
125115 /// <summary>
@@ -139,18 +129,15 @@ public async Task DeclineTransaction(Guid estateId,
139129 String responseMessage ,
140130 CancellationToken cancellationToken )
141131 {
142- IAggregateRepository < TransactionAggregate > transactionAggregateRepository =
143- this . AggregateRepositoryManager . GetAggregateRepository < TransactionAggregate > ( estateId ) ;
144-
145- TransactionAggregate transactionAggregate = await transactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
132+ TransactionAggregate transactionAggregate = await this . TransactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
146133
147134 transactionAggregate . DeclineTransaction ( operatorIdentifier ,
148135 operatorResponse . ResponseCode ,
149136 operatorResponse . ResponseMessage ,
150137 ( ( Int32 ) transactionResponseCode ) . ToString ( ) . PadLeft ( 4 , '0' ) ,
151138 responseMessage ) ;
152139
153- await transactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
140+ await this . TransactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
154141 }
155142
156143 /// <summary>
@@ -165,14 +152,11 @@ public async Task DeclineTransactionLocally(Guid estateId,
165152 ( String responseMessage , TransactionResponseCode responseCode ) validationResult ,
166153 CancellationToken cancellationToken )
167154 {
168- IAggregateRepository < TransactionAggregate > transactionAggregateRepository =
169- this . AggregateRepositoryManager . GetAggregateRepository < TransactionAggregate > ( estateId ) ;
170-
171- TransactionAggregate transactionAggregate = await transactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
155+ TransactionAggregate transactionAggregate = await this . TransactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
172156
173157 transactionAggregate . DeclineTransactionLocally ( ( ( Int32 ) validationResult . responseCode ) . ToString ( ) . PadLeft ( 4 , '0' ) , validationResult . responseMessage ) ;
174158
175- await transactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
159+ await this . TransactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
176160 }
177161
178162 /// <summary>
@@ -186,10 +170,7 @@ public async Task<TransactionAggregate> GetAggregate(Guid estateId,
186170 Guid transactionId ,
187171 CancellationToken cancellationToken )
188172 {
189- IAggregateRepository < TransactionAggregate > transactionAggregateRepository =
190- this . AggregateRepositoryManager . GetAggregateRepository < TransactionAggregate > ( estateId ) ;
191-
192- TransactionAggregate transactionAggregate = await transactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
173+ TransactionAggregate transactionAggregate = await this . TransactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
193174 return transactionAggregate ;
194175 }
195176
@@ -209,14 +190,11 @@ public async Task RecordAdditionalRequestData(Guid estateId,
209190 {
210191 if ( additionalTransactionRequestMetadata != null && additionalTransactionRequestMetadata . Any ( ) )
211192 {
212- IAggregateRepository < TransactionAggregate > transactionAggregateRepository =
213- this . AggregateRepositoryManager . GetAggregateRepository < TransactionAggregate > ( estateId ) ;
214-
215- TransactionAggregate transactionAggregate = await transactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
193+ TransactionAggregate transactionAggregate = await this . TransactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
216194
217195 transactionAggregate . RecordAdditionalRequestData ( operatorIdentifier , additionalTransactionRequestMetadata ) ;
218196
219- await transactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
197+ await this . TransactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
220198 }
221199 }
222200
@@ -235,14 +213,11 @@ public async Task RecordAdditionalResponseData(Guid estateId,
235213 {
236214 if ( additionalTransactionResponseMetadata != null && additionalTransactionResponseMetadata . Any ( ) )
237215 {
238- IAggregateRepository < TransactionAggregate > transactionAggregateRepository =
239- this . AggregateRepositoryManager . GetAggregateRepository < TransactionAggregate > ( estateId ) ;
240-
241- TransactionAggregate transactionAggregate = await transactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
216+ TransactionAggregate transactionAggregate = await this . TransactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
242217
243218 transactionAggregate . RecordAdditionalResponseData ( operatorIdentifier , additionalTransactionResponseMetadata ) ;
244219
245- await transactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
220+ await this . TransactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
246221 }
247222 }
248223
@@ -254,14 +229,11 @@ public async Task RecordAdditionalResponseData(Guid estateId,
254229 /// <param name="cancellationToken">The cancellation token.</param>
255230 public async Task RequestEmailReceipt ( Guid estateId , Guid transactionId , String customerEmailAddress , CancellationToken cancellationToken )
256231 {
257- IAggregateRepository < TransactionAggregate > transactionAggregateRepository =
258- this . AggregateRepositoryManager . GetAggregateRepository < TransactionAggregate > ( estateId ) ;
259-
260- TransactionAggregate transactionAggregate = await transactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
232+ TransactionAggregate transactionAggregate = await this . TransactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
261233
262234 transactionAggregate . RequestEmailReceipt ( customerEmailAddress ) ;
263235
264- await transactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
236+ await this . TransactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
265237 }
266238
267239 /// <summary>
@@ -288,14 +260,11 @@ public async Task StartTransaction(Guid transactionId,
288260 Decimal ? transactionAmount ,
289261 CancellationToken cancellationToken )
290262 {
291- IAggregateRepository < TransactionAggregate > transactionAggregateRepository =
292- this . AggregateRepositoryManager . GetAggregateRepository < TransactionAggregate > ( estateId ) ;
293-
294- TransactionAggregate transactionAggregate = await transactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
263+ TransactionAggregate transactionAggregate = await this . TransactionAggregateRepository . GetLatestVersion ( transactionId , cancellationToken ) ;
295264
296265 transactionAggregate . StartTransaction ( transactionDateTime , transactionNumber , transactionType , transactionReference , estateId , merchantId , deviceIdentifier , transactionAmount ) ;
297266
298- await transactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
267+ await this . TransactionAggregateRepository . SaveChanges ( transactionAggregate , cancellationToken ) ;
299268 }
300269
301270 #endregion
0 commit comments