/// <summary>
            /// Get the drop and declare tender transaction.
            /// </summary>
            /// <param name="transactionId">The transaction identifier.</param>
            /// <returns>The drop and declare tender transaction.</returns>
            private DropAndDeclareTransaction GetDropAndDeclareTransaction(string transactionId)
            {
                var getDropAndDeclareTransactionDataRequest = new GetDropAndDeclareTransactionDataRequest(transactionId, QueryResultSettings.SingleRecord);
                DropAndDeclareTransaction transaction       = this.Context.Runtime.Execute <EntityDataServiceResponse <DropAndDeclareTransaction> >(getDropAndDeclareTransactionDataRequest, this.Context).PagedEntityCollection.FirstOrDefault();

                var getDropAndDeclareTransactionTenderDetailsDataRequest = new GetDropAndDeclareTransactionTenderDetailsDataRequest(transactionId, QueryResultSettings.AllRecords);
                PagedResult <TenderDetail> tenderDetails = this.Context.Runtime.Execute <EntityDataServiceResponse <TenderDetail> >(getDropAndDeclareTransactionTenderDetailsDataRequest, this.Context).PagedEntityCollection;

                transaction.TenderDetails = tenderDetails.Results;
                return(transaction);
            }
Esempio n. 2
0
            /// <summary>
            /// Invoke the method to save drop and declare transactions.
            /// </summary>
            /// <param name="request">Request context.</param>
            /// <returns>Returns response for save drop and declare.</returns>
            private static SaveDropAndDeclareServiceResponse SaveDropAndDeclareTransactions(SaveDropAndDeclareServiceRequest request)
            {
                StoreOperationServiceHelper.ValidateTenderDeclarationCountingDifference(request);

                DropAndDeclareTransaction tenderDropAndDeclare = StoreOperationServiceHelper.ConvertTenderDropAndDeclareTransaction(request);

                // If the previously created drop transaction response did not get received due to network connection issue.
                // On client retry, check if it was already saved. If true, returns saved object.
                var getDropAndDeclareTransactionDataRequest = new GetDropAndDeclareTransactionDataRequest(tenderDropAndDeclare.Id, QueryResultSettings.SingleRecord);
                DropAndDeclareTransaction transaction       = request.RequestContext.Runtime.Execute <EntityDataServiceResponse <DropAndDeclareTransaction> >(getDropAndDeclareTransactionDataRequest, request.RequestContext).PagedEntityCollection.FirstOrDefault();

                if (transaction != null)
                {
                    var getDropAndDeclareTransactionTenderDetailsDataRequest = new GetDropAndDeclareTransactionTenderDetailsDataRequest(tenderDropAndDeclare.Id, QueryResultSettings.AllRecords);
                    transaction.TenderDetails = request.RequestContext.Runtime.Execute <EntityDataServiceResponse <TenderDetail> >(getDropAndDeclareTransactionTenderDetailsDataRequest, request.RequestContext).PagedEntityCollection.Results;
                }
                else
                {
                    var saveDropAndDeclareTransactionDataRequest = new SaveDropAndDeclareTransactionDataRequest(tenderDropAndDeclare);
                    transaction = request.RequestContext.Runtime.Execute <SingleEntityDataServiceResponse <DropAndDeclareTransaction> >(saveDropAndDeclareTransactionDataRequest, request.RequestContext).Entity;
                }

                return(new SaveDropAndDeclareServiceResponse(transaction));
            }
Esempio n. 3
0
            private EntityDataServiceResponse <DropAndDeclareTransaction> GetDropAndDeclareTransactions(GetDropAndDeclareTransactionDataRequest request)
            {
                ThrowIf.NullOrWhiteSpace(request.DropAndDeclareTransactionId, "request.DropAndDeclareTransactionId");
                ThrowIf.Null(request.QueryResultSettings, "request.QueryResultSettings");

                var query = new SqlPagedQuery(request.QueryResultSettings)
                {
                    From  = DropAndDeclareTransactionsView,
                    Where = "TRANSACTIONID = @TransactionId",
                };

                query.Parameters["@TransactionId"] = request.DropAndDeclareTransactionId;

                PagedResult <DropAndDeclareTransaction> dropAndDeclareTransaction;

                using (var sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    dropAndDeclareTransaction = sqlServerDatabaseContext.ReadEntity <DropAndDeclareTransaction>(query);
                }

                return(new EntityDataServiceResponse <DropAndDeclareTransaction>(dropAndDeclareTransaction));
            }