/// <summary>
            /// Gets a default logistics postal address for India.
            /// </summary>
            /// <param name="request">The get warehouse address India data request.</param>
            /// <returns>Matching address.</returns>
            /// <remarks>
            /// Search address as warehouse -> site -> legal entity.
            /// </remarks>
            private SingleEntityDataServiceResponse <Address> GetWarehouseAddressIndia(GetWarehouseAddressIndiaDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.NullOrWhiteSpace(request.WarehouseId, "request.WarehouseId");

                IndiaTaxL2CacheDataStoreAccessor level2CacheDataAccessor = this.GetIndiaTaxL2CacheDataStoreAccessor(request.RequestContext);

                bool    found;
                bool    updateL2Cache;
                Address result = DataManager.GetDataFromCache(() => level2CacheDataAccessor.GetWarehouseAddressIndia(request.WarehouseId), out found, out updateL2Cache);

                if (!found)
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters["@nv_InventLocationId"]         = request.WarehouseId;
                    parameters["@nv_InventLocationDataAreaId"] = request.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;

                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        result = sqlServerDatabaseContext.ExecuteStoredProcedure <Address>(GetWarehouseAddressIndiaName, parameters).SingleOrDefault();
                    }

                    updateL2Cache &= result != null;
                }

                if (updateL2Cache)
                {
                    level2CacheDataAccessor.PutWarehouseAddressIndia(request.WarehouseId, result);
                }

                return(new SingleEntityDataServiceResponse <Address>(result));
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Inserts audit log.
            /// </summary>
            /// <param name="request">The <see cref="InsertAuditLogDataRequest"/>log request.</param>
            /// <returns>The <see cref="NullResponse"/>response.</returns>
            private NullResponse InsertAuditLog(InsertAuditLogDataRequest request)
            {
                // Insert
                ChannelConfiguration channelConfiguration = request.RequestContext.GetChannelConfiguration();

                // RetailLog is an AX table, DataAreaId field is mandatory. We need to confirm channelConfiguration is present
                // before inserting data to RetailLog, otherwise P-job will fail due to DataAreaId is missing.
                if (channelConfiguration != null)
                {
                    var parameters = new ParameterSet();
                    parameters["@RETAILLOGID"]        = DateTimeOffset.UtcNow.Ticks;
                    parameters["@DATE"]               = request.RequestContext.GetNowInChannelTimeZone().DateTime;
                    parameters["@CODEUNIT"]           = request.Source;
                    parameters["@LOGSTRING"]          = request.LogEntry;
                    parameters["@LOGLEVEL"]           = request.LogLevel;
                    parameters["@STOREID"]            = request.StoreId;
                    parameters["@TERMINALID"]         = request.TerminalId;
                    parameters["@DURATIONINMILLISEC"] = request.DurationInMilliseconds;
                    parameters["@DATAAREAID"]         = channelConfiguration.InventLocationDataAreaId;

                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(AuditLogSqlServerDataService.InsertAuditLogSprocName, parameters);
                    }
                }

                return(new NullResponse());
            }
            /// <summary>
            /// Gets Receipt Header tax information for India.
            /// </summary>
            /// <param name="request">The get receipt header tax info India data request.</param>
            /// <returns>Receipt Header tax info.</returns>
            private SingleEntityDataServiceResponse <ReceiptHeaderTaxInfoIndia> GetReceiptHeaderTaxInfoIndia(GetReceiptHeaderTaxInfoIndiaDataRequest request)
            {
                ThrowIf.Null(request, "request");

                IndiaTaxL2CacheDataStoreAccessor level2CacheDataAccessor = this.GetIndiaTaxL2CacheDataStoreAccessor(request.RequestContext);
                bool found;
                bool updateL2Cache;
                ReceiptHeaderTaxInfoIndia result = DataManager.GetDataFromCache(() => level2CacheDataAccessor.GetReceiptHeaderTaxInfoIndia(request.QueryResultSettings.ColumnSet), out found, out updateL2Cache);

                if (!found)
                {
                    ParameterSet parameters = new ParameterSet();

                    parameters["@bi_ChannelId"] = request.RequestContext.GetPrincipal().ChannelId;

                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        result = sqlServerDatabaseContext.ExecuteStoredProcedure <ReceiptHeaderTaxInfoIndia>(GetReceiptHeaderTaxInfoIndiaName, parameters).SingleOrDefault();
                    }

                    updateL2Cache &= result != null;
                }

                if (updateL2Cache)
                {
                    level2CacheDataAccessor.PutReceiptHeaderTaxInfoIndia(request.QueryResultSettings.ColumnSet, result);
                }

                return(new SingleEntityDataServiceResponse <ReceiptHeaderTaxInfoIndia>(result));
            }
Ejemplo n.º 4
0
            /// <summary>
            /// The data service method to get tax code intervals.
            /// </summary>
            /// <param name="request">The data service request.</param>
            /// <returns>The data service response.</returns>
            private EntityDataServiceResponse <TaxCodeInterval> GetTaxCodeIntervals(GetTaxCodeIntervalsDataRequest request)
            {
                ThrowIf.Null(request.ItemTaxGroupId, "itemTaxGroupId");

                var taxDataManager = this.GetDataManagerInstance(request.RequestContext);
                TaxL2CacheDataStoreAccessor level2CacheDataAccessor = (TaxL2CacheDataStoreAccessor)taxDataManager.DataStoreManagerInstance.RegisteredAccessors[DataStoreType.L2Cache];

                bool found;
                bool updateL2Cache;
                ReadOnlyCollection <TaxCodeInterval> result = DataManager.GetDataFromCache(() => level2CacheDataAccessor.GetTaxCodeIntervals(request.SalesTaxGroupId, request.ItemTaxGroupId), out found, out updateL2Cache);

                if (!found)
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters[DatabaseAccessor.ChannelIdVariableName] = request.RequestContext.GetPrincipal().ChannelId;
                    parameters["@nvc_SalesTaxGroup"]  = request.SalesTaxGroupId ?? string.Empty;
                    parameters["@nvc_ItemTaxGroup"]   = request.ItemTaxGroupId ?? string.Empty;
                    parameters["@dt_TransactionDate"] = request.TransactionDate.DateTime;

                    using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request))
                    {
                        result = databaseContext.ExecuteStoredProcedure <TaxCodeInterval>(GetTaxCodeIntervalsSprocName, parameters).Results;
                    }

                    updateL2Cache &= result != null &&
                                     result.Count < MaxCachedCollectionSize;
                }

                if (updateL2Cache)
                {
                    level2CacheDataAccessor.PutTaxCodeIntervals(request.SalesTaxGroupId, request.ItemTaxGroupId, request.TransactionDate, result);
                }

                return(new EntityDataServiceResponse <TaxCodeInterval>(result.AsPagedResult()));
            }
            /// <summary>
            /// Gets reports configuration. If report identifier is null or empty, it will return configuration of all reports.
            /// </summary>
            /// <param name="context">The request context.</param>
            /// <param name="reportId">The report identifier.</param>
            /// <param name="settings">The query result settings.</param>
            /// <returns>Report configuration data table.</returns>
            private DataTable GetReportsConfiguration(RequestContext context, string reportId, QueryResultSettings settings)
            {
                ThrowIf.Null(settings, "settings");

                string reportConfigSPName = GetReportConfigSPName;

                ParameterSet parameters = new ParameterSet();

                parameters[DatabaseAccessor.ChannelIdVariableName] = context.GetPrincipal().ChannelId;
                parameters[ParamUserId] = context.GetPrincipal().UserId;

                if (!string.IsNullOrEmpty(reportId))
                {
                    parameters[ParamReportId] = reportId;
                    reportConfigSPName        = GetReportConfigByIdSPName;
                }

                DataSet outputDataSet;

                using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(context, settings))
                {
                    outputDataSet = sqlServerDatabaseContext.ExecuteStoredProcedureDataSet(reportConfigSPName, parameters);
                }

                if (outputDataSet != null && outputDataSet.Tables.Count > 0)
                {
                    outputDataSet.Tables[0].TableName = OutputTableName;
                    return(outputDataSet.Tables[0]);
                }

                return(null);
            }
            private EntityDataServiceResponse <LoyaltyGroup> GetLoyaltyGroupsAndTiersByCardNumber(GetLoyaltyGroupsAndTiersDataRequest request)
            {
                ThrowIf.Null(request.LoyaltyCardNumber, "loyaltyCardNumber");

                ParameterSet parameters = new ParameterSet();

                parameters["@nvc_LoyaltyCardNumber"] = request.LoyaltyCardNumber;
                parameters["@nvc_Locale"]            = request.RequestContext.LanguageId;

                // Get all loyalty groups of the loyalty cards.
                ReadOnlyCollection <LoyaltyGroup> loyaltyGroups;

                using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    loyaltyGroups = sqlServerDatabaseContext.ExecuteNonPagedStoredProcedure <LoyaltyGroup>(LoyaltySqlServerDataService.GetLoyaltyGroupsByLoyaltyCardSprocName, parameters);
                }

                // Get all loyalty tiers of each loyalty group
                foreach (var loyaltyGroup in loyaltyGroups)
                {
                    loyaltyGroup.LoyaltyTiers     = this.GetLoyaltyTiers(request, loyaltyGroup.RecordId);
                    loyaltyGroup.LoyaltyCardTiers = this.GetActiveOrFutureLoyaltyCardTiers(request, loyaltyGroup.RecordId);
                }

                return(new EntityDataServiceResponse <LoyaltyGroup>(loyaltyGroups.AsPagedResult()));
            }
            /// <summary>
            /// Gets the reason sub codes with given reason code identifier or reason sub code identifier.
            /// </summary>
            /// <param name="reasonCodeIds">The reason code identifier.</param>
            /// <param name="reasonSubCodeId">The reason sub code identifier.</param>
            /// <param name="settings">The query result settings.</param>
            /// <param name="request">The get reason codes data request.</param>
            /// <returns>The info sub codes.</returns>
            private static PagedResult <ReasonSubCode> GetReasonSubCodes(IEnumerable <string> reasonCodeIds, string reasonSubCodeId, QueryResultSettings settings, GetReasonCodesDataRequest request)
            {
                ThrowIf.Null(reasonCodeIds, "reasonCodeIds");
                ThrowIf.Null(settings, "settings");

                var query = new SqlPagedQuery(settings)
                {
                    From    = ReasonSubCodeFunctionName,
                    Aliased = true
                };

                BuildSubReasonCodesQuery(reasonCodeIds, reasonSubCodeId, query, request.RequestContext);

                PagedResult <ReasonSubCode> reasonSubcodes;

                using (StringIdTableType type = new StringIdTableType(reasonCodeIds, "REASONCODEID"))
                {
                    query.Parameters["@TVP_INFOCODEIDTABLETYPE"] = type;

                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        reasonSubcodes = sqlServerDatabaseContext.ReadEntity <ReasonSubCode>(query);
                    }

                    return(reasonSubcodes);
                }
            }
Ejemplo n.º 8
0
            private static GetUnitOfMeasureConversionDataResponse GetUnitOfMeasureConversion(GetUnitOfMeasureConversionDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.ItemUnitConversions, "request.ItemUnitConversions");
                ThrowIf.Null(request.QueryResultSettings, "request.QueryResultSettings");

                var query = new SqlPagedQuery(request.QueryResultSettings)
                {
                    From    = GetUnitOfMeasureConversionsFunctionName,
                    OrderBy = "ITEMID, FROMUNITID, TOUNITID",
                };

                PagedResult <UnitOfMeasureConversion> unitOfMeasureConversions;

                using (ItemUnitConversionTableType type = new ItemUnitConversionTableType(request.ItemUnitConversions))
                {
                    query.Parameters[DataAreaIdVariableName]       = request.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;
                    query.Parameters[ItemUnitConversionsTableType] = type.DataTable;

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

                return(new GetUnitOfMeasureConversionDataResponse(unitOfMeasureConversions));
            }
Ejemplo n.º 9
0
            private static NullResponse DeleteCart(DeleteCartDataRequest request)
            {
                ThrowIf.Null(request, "request");

                int errorCode;

                using (StringIdTableType transactionIdsTableType = new StringIdTableType(request.SalesTransactionIds, string.Empty))
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters[SalesTransactionIdsTableTypeVariableName] = transactionIdsTableType;

                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        errorCode = sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(DeleteSalesTransactionsSprocName, parameters);
                    }
                }

                if (errorCode != (int)DatabaseErrorCodes.Success)
                {
                    if (errorCode == (int)DatabaseErrorCodes.AuthorizationError)
                    {
                        throw new SecurityException(SecurityErrors.Microsoft_Dynamics_Commerce_Runtime_AuthorizationFailed, "One or more transactions could not be deleted.");
                    }

                    throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError, errorCode, "Unable to delete transactions.");
                }

                return(new NullResponse());
            }
            private EntityDataServiceResponse <SalesAffiliationLoyaltyTier> GetLoyaltyCardAffiliations(GetLoyaltyCardAffiliationsDataRequest request)
            {
                ThrowIf.Null(request.LoyaltyCardNumber, "loyaltyCardNumber");

                ParameterSet parameters = new ParameterSet();

                parameters["@nvc_LoyaltyCardNumber"] = request.LoyaltyCardNumber;
                parameters["@dt_channelLocalDate"]   = request.RequestContext.GetNowInChannelTimeZone().Date;

                ReadOnlyCollection <AffiliationLoyaltyTier> affiliations;

                using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    affiliations = sqlServerDatabaseContext.ExecuteNonPagedStoredProcedure <AffiliationLoyaltyTier>(LoyaltySqlServerDataService.GetActiveLoyaltyCardTiersSprocName, parameters);
                }

                ReadOnlyCollection <SalesAffiliationLoyaltyTier> salesAffiliations = affiliations.Select(loyaltyAffiliation =>
                                                                                                         new SalesAffiliationLoyaltyTier()
                {
                    AffiliationId   = loyaltyAffiliation.AffiliationId,
                    LoyaltyTierId   = loyaltyAffiliation.LoyaltyTierId,
                    AffiliationType = RetailAffiliationType.Loyalty,
                    ChannelId       = request.RequestContext.GetPrincipal().ChannelId,
                    ReceiptId       = request.Transaction.ReceiptId,
                    StaffId         = request.Transaction.StaffId,
                    TerminalId      = request.Transaction.TerminalId,
                    TransactionId   = request.Transaction.Id
                }).AsReadOnly();

                return(new EntityDataServiceResponse <SalesAffiliationLoyaltyTier>(salesAffiliations.AsPagedResult()));
            }
            private EntityDataServiceResponse <OrgUnitAddress> GetOrgUnitAddress(GetOrgUnitAddressDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.ChannelIds, "request.ChannelIds");
                ThrowIf.Null(request.QueryResultSettings, "request.QueryResultSettings");

                var query = new SqlPagedQuery(request.QueryResultSettings)
                {
                    From    = OrgUnitAddressView,
                    OrderBy = "CHANNELID"
                };

                PagedResult <OrgUnitAddress> results;
                IEnumerable <string>         distinctChannelIds = request.ChannelIds.Distinct <long>().Select <long, string>(id => id.ToString());

                using (StringIdTableType channelIdsTable = new StringIdTableType(distinctChannelIds, "CHANNELID"))
                {
                    query.Parameters["@TVP_CHANNELID"] = channelIdsTable;
                    using (var sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        results = sqlServerDatabaseContext.ReadEntity <OrgUnitAddress>(query);
                    }
                }

                return(new EntityDataServiceResponse <OrgUnitAddress>(results));
            }
Ejemplo n.º 12
0
            private EntityDataServiceResponse <ZipCodeInfo> GetZipCodes(GetZipPostalCodeDataRequest request)
            {
                ThrowIf.Null(request.CountryRegionCode, "countryRegionCode");
                ThrowIf.Null(request.StateId, "stateId");
                ThrowIf.Null(request.CountyId, "countyId");
                ThrowIf.Null(request.City, "city");
                ThrowIf.Null(request.District, "districtId");

                ParameterSet filters = new ParameterSet();

                filters[AddressServiceConstants.CountryRegionId]   = request.CountryRegionCode;
                filters[AddressServiceConstants.StateProvinceId]   = request.StateId;
                filters[AddressServiceConstants.CountyId]          = request.CountyId;
                filters[AddressServiceConstants.CityComponentName] = request.City;
                filters[AddressServiceConstants.DistrictId]        = request.District;

                PagedResult <ZipCodeInfo> zipCodes;

                using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    zipCodes = sqlServerDatabaseContext.ExecuteStoredProcedure <ZipCodeInfo>(GetZipCodesInfoSprocName, filters);
                }

                return(new EntityDataServiceResponse <ZipCodeInfo>(zipCodes));
            }
Ejemplo n.º 13
0
            /// <summary>
            /// Unlock the current user.
            /// </summary>
            /// <param name="request">The data service request.</param>
            /// <returns>The data service response.</returns>
            private SingleEntityDataServiceResponse <bool> UnLockUserAtLogOff(UnlockUserAtLogOffDataRequest request)
            {
                ParameterSet parameters = new ParameterSet();

                parameters[ChannelIdParamName]  = request.ChannelId;
                parameters[StaffIdParamName]    = request.StaffId;
                parameters[DataAreaIdParamName] = request.DataAreaId;
                ParameterSet outputParameters = new ParameterSet();

                outputParameters[ReturnValueParamName] = 0;

                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request))
                {
                    databaseContext.ExecuteStoredProcedureScalar(UnlockUserSprocName, parameters, outputParameters);
                }

                bool result = false;

                if ((int)outputParameters[ReturnValueParamName] == 1)
                {
                    result = true;
                }

                EmployeeL2CacheDataStoreAccessor cacheAccessor = GetCacheAccessor(request.RequestContext);

                cacheAccessor.ClearCacheLockUserAtLogOn(request.TerminalId, request.StaffId);

                // unlocking the user has the same meaning as deleting the user session on the terminal
                cacheAccessor.ClearCacheIsEmployeeSessionOpenOnTerminal(request.TerminalId, request.StaffId);

                return(new SingleEntityDataServiceResponse <bool>(result));
            }
Ejemplo n.º 14
0
            private static SingleEntityDataServiceResponse <decimal> GetCustomerLocalPendingBalance(GetCustomerAccountLocalPendingBalanceDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.NullOrWhiteSpace(request.AccountNumber, "request.AccountNumber");
                decimal tenderedAmount = decimal.Zero;
                decimal depositsAmount = decimal.Zero;

                ParameterSet parameters = new ParameterSet();

                parameters["@nvc_AccountNumber"] = request.AccountNumber;
                parameters["@nvc_StoreId"]       = request.RequestContext.GetOrgUnit().OrgUnitNumber;
                parameters["@nvc_PosOperation"]  = (int)RetailOperation.PayCustomerAccount;
                parameters["@i_LastCounter"]     = request.LastReplicationCounter;
                parameters["@nvc_DataAreaId"]    = request.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;

                ParameterSet outputParameters = new ParameterSet();

                outputParameters["@d_tenderAmount"]  = tenderedAmount;
                outputParameters["@d_depositAmount"] = depositsAmount;

                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                {
                    databaseContext.ExecuteStoredProcedureScalar(LocalPendingTransactionsAmountSprocName, parameters, outputParameters);
                }

                tenderedAmount = Convert.ToDecimal(outputParameters["@d_tenderAmount"]);
                depositsAmount = Convert.ToDecimal(outputParameters["@d_depositAmount"]);

                return(new SingleEntityDataServiceResponse <decimal>(tenderedAmount - depositsAmount));
            }
Ejemplo n.º 15
0
            private GetCountryRegionDataResponse GetCountryRegion(GetCountryRegionDataRequest request)
            {
                ThrowIf.Null(request.QueryResultSettings, "settings");

                string languageId = request.LanguageId;

                if (string.IsNullOrWhiteSpace(languageId))
                {
                    var getDefaultLanguageIdDataRequest = new GetDefaultLanguageIdDataRequest();
                    languageId = request.RequestContext.Runtime.Execute <SingleEntityDataServiceResponse <string> >(getDefaultLanguageIdDataRequest, request.RequestContext).Entity;
                }

                var parameterSet = new ParameterSet();

                parameterSet["nvc_LanguageId"] = languageId;

                Tuple <PagedResult <CountryRegionInfo>, ReadOnlyCollection <AddressFormattingInfo> > countryRegions;

                using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    countryRegions = sqlServerDatabaseContext.ExecuteStoredProcedure <CountryRegionInfo, AddressFormattingInfo>(GetCountryRegionInfoSprocName, parameterSet);
                }

                return(new GetCountryRegionDataResponse(countryRegions.Item1, countryRegions.Item2));
            }
            /// <summary>
            /// Delete the shift from shift staging table.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>A null response.</returns>
            private NullResponse DeleteShiftStagingTable(DeleteShiftDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.Shift, "request.Shift");

                Shift shift = request.Shift;

                ParameterSet parameters = new ParameterSet();

                parameters[DatabaseAccessor.ChannelIdVariableName] = request.RequestContext.GetPrincipal().ChannelId;
                parameters[TerminalIdVariableName] = shift.TerminalId;
                parameters[ShiftIdVariableName]    = shift.ShiftId;
                parameters[RowVersionViarableName] = shift.RowVersion;

                int errorCode;

                using (var sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    errorCode = sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(DeleteShiftStagingSprocName, parameters);
                }

                if (errorCode != (int)DatabaseErrorCodes.Success)
                {
                    throw new StorageException(
                              StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError,
                              errorCode,
                              string.Format("Unable to execute the stored procedure {0}.", DeleteShiftStagingSprocName));
                }

                return(new NullResponse());
            }
Ejemplo n.º 17
0
            private EntityDataServiceResponse <NonSalesTransaction> GetCurrentShiftNonSalesTransactions(GetCurrentShiftNonSalesTransactionsDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.NonSalesTransaction, "request.NonSalesTransaction");

                string transactionId = request.NonSalesTransactionId;

                if (string.IsNullOrWhiteSpace(request.NonSalesTransactionId))
                {
                    transactionId = string.Empty;
                }

                var transaction = request.NonSalesTransaction;
                var parameters  = new ParameterSet();

                parameters[DatabaseAccessor.ChannelIdVariableName] = request.RequestContext.GetPrincipal().ChannelId;
                parameters["@nvc_TRANSACTIONTYPE"] = transaction.TransactionTypeValue;
                parameters["@nvc_TENDERTYPE"]      = transaction.TenderTypeId;
                parameters["@nvc_BATCHTERMINALID"] = transaction.ShiftTerminalId;
                parameters["@bi_BATCHID"]          = transaction.ShiftId;
                parameters["@nvc_TransactionId"]   = transactionId;

                PagedResult <NonSalesTransaction> results;

                using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    results = sqlServerDatabaseContext.ExecuteStoredProcedure <NonSalesTransaction>("GETCURRENTSHIFTNONSALETENDERS", parameters);
                }

                return(new EntityDataServiceResponse <NonSalesTransaction>(results));
            }
Ejemplo n.º 18
0
            private static NullResponse UpdateReturnQuantities(UpdateReturnQuantitiesDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.SalesLines, "request.SalesLines");

                foreach (var salesline in request.SalesLines)
                {
                    if (salesline.IsReturnByReceipt)
                    {
                        ParameterSet parameters = new ParameterSet();
                        parameters[DatabaseAccessor.ChannelIdVariableName] = salesline.ReturnChannelId;
                        parameters["@nvc_StoreNumber"]   = salesline.ReturnStore;
                        parameters["@nvc_TerminalId"]    = salesline.ReturnTerminalId;
                        parameters["@nvc_TransactionId"] = salesline.ReturnTransactionId;
                        parameters["@nu_LineNumber"]     = salesline.ReturnLineNumber;
                        parameters["@nu_Quantity"]       = salesline.Quantity;

                        using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                        {
                            databaseContext.ExecuteStoredProcedureNonQuery("UPDATERETURNQUANTITY", parameters);
                        }
                    }
                }

                return(new NullResponse());
            }
            /// <summary>
            /// Gets the customer account by external identity.
            /// </summary>
            /// <param name="request">The data service request.</param>
            /// <returns>The data service response.</returns>
            private SingleEntityDataServiceResponse <CommerceIdentityProvider> GetCommerceIdentityProviderByIssuer(GetCommerceIdentityProviderByIssuerDataRequest request)
            {
                CommerceIdentityProviderL2CacheDataStoreAccessor levelL2CacheDataAccessor = this.GetCommerceIdentityProviderL2CacheDataStoreAccessor(request.RequestContext);
                bool foundInCache;
                bool updateCache;

                CommerceIdentityProvider commerceIdentityProvider = DataManager.GetDataFromCache(() => levelL2CacheDataAccessor.GetCommerceIdentityProviderByIssuer(request.CommerceIdentityProviderIssuer), out foundInCache, out updateCache);

                if (!foundInCache)
                {
                    var getIdentityProviderParameters = new ParameterSet();
                    PagedResult <CommerceRelyingParty> identityProviderRelyingParties;
                    getIdentityProviderParameters["@nvc_Issuer"] = request.CommerceIdentityProviderIssuer;
                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        commerceIdentityProvider = sqlServerDatabaseContext.ExecuteStoredProcedure <CommerceIdentityProvider>(GetIdentityProviderSprocName, getIdentityProviderParameters).Results.FirstOrDefault();

                        if (commerceIdentityProvider != null)
                        {
                            var getRelyingPartiesParameters = new ParameterSet();
                            getRelyingPartiesParameters["@bi_ProviderId"] = commerceIdentityProvider.RecordId;
                            identityProviderRelyingParties = sqlServerDatabaseContext.ExecuteStoredProcedure <CommerceRelyingParty>(GetRelyingPartiesByIdentityProviderSprocName, getRelyingPartiesParameters);

                            commerceIdentityProvider.CommerceRelyingParties = identityProviderRelyingParties.Results.ToList();
                        }
                    }
                }

                if (updateCache && commerceIdentityProvider != null)
                {
                    levelL2CacheDataAccessor.CacheCommerceIdentityProviderByIssuer(request.CommerceIdentityProviderIssuer, commerceIdentityProvider);
                }

                return(new SingleEntityDataServiceResponse <CommerceIdentityProvider>(commerceIdentityProvider));
            }
            /// <summary>
            /// Gets the setting that shows whether to apply inter-state tax for India or not.
            /// </summary>
            /// <param name="request">The get apply interstate tax India data request.</param>
            /// <returns>The setting that shows whether to apply inter-state tax for India or not.</returns>
            private SingleEntityDataServiceResponse <ApplyInterStateTaxIndia> GetApplyInterstateTaxIndia(GetApplyInterstateTaxIndiaDataRequest request)
            {
                ThrowIf.Null(request, "request");

                IndiaTaxL2CacheDataStoreAccessor level2CacheDataAccessor = this.GetIndiaTaxL2CacheDataStoreAccessor(request.RequestContext);

                bool found;
                bool updateL2Cache;
                ApplyInterStateTaxIndia result = DataManager.GetDataFromCache(() => level2CacheDataAccessor.GetApplyInterStateTaxIndia(request.QueryResultSettings.ColumnSet), out found, out updateL2Cache);

                if (!found)
                {
                    // Fetches it from database if no setting was cached.
                    // Input parameters
                    ParameterSet parameters = new ParameterSet();
                    parameters["@bi_ChannelId"] = request.RequestContext.GetPrincipal().ChannelId;

                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        result = sqlServerDatabaseContext.ExecuteStoredProcedure <ApplyInterStateTaxIndia>(GetApplyInterStateTaxIndiaName, parameters).SingleOrDefault();
                    }

                    updateL2Cache &= result != null;
                }

                if (updateL2Cache)
                {
                    // Caches the result if it is fetched from database.
                    level2CacheDataAccessor.PutApplyInterStateTaxIndia(request.QueryResultSettings.ColumnSet, result);
                }

                return(new SingleEntityDataServiceResponse <ApplyInterStateTaxIndia>(result));
            }
Ejemplo n.º 21
0
            /// <summary>
            /// Creates or Updates the retail device.
            /// </summary>
            /// <param name="request">The data service request.</param>
            /// <returns>The data service response.</returns>
            private NullResponse CreateOrUpdateDevice(CreateOrUpdateDeviceDataRequest request)
            {
                ThrowIf.Null(request.Device, "request.Device");

                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters["@dt_ActivatedDateTime"]           = request.Device.ActivatedDateTime;
                    parameters["@i_ActivationStatus"]             = request.Device.ActivationStatus;
                    parameters["@nvc_DeactivateComments"]         = request.Device.DeactivateComments;
                    parameters["@dt_DeactivatedDateTime"]         = request.Device.DeactivatedDateTime;
                    parameters["@nvc_Description"]                = request.Device.Description;
                    parameters["@nvc_DeviceId"]                   = request.Device.DeviceNumber;
                    parameters["@nvc_Terminal"]                   = request.Device.TerminalId;
                    parameters["@bi_TypeRecordId"]                = request.Device.DeviceTypeRecordId;
                    parameters["@nvc_DeviceTokenData"]            = request.Device.TokenData;
                    parameters["@nvc_DeviceTokenSalt"]            = request.Device.TokenSalt;
                    parameters["@nvc_DeviceTokenAlgorithm"]       = request.Device.TokenAlgorithm;
                    parameters["@dt_DeviceTokenIssueTime"]        = request.Device.TokenIssueTime;
                    parameters["@i_UseInMemoryDeviceDataStorage"] = request.Device.UseInMemoryDeviceDataStorage;
                    parameters["@bi_RecordId"] = request.Device.RecordId;

                    databaseContext.ExecuteStoredProcedureNonQuery(CreateUpdateDeviceSprocName, parameters);
                }

                DeviceL2CacheDataStoreAccessor levelL2CacheDataAccessor = this.GetDeviceL2CacheDataStoreAccessor(request.RequestContext);

                levelL2CacheDataAccessor.ClearCacheDeviceById(request.Device.DeviceNumber);

                return(new NullResponse());
            }
 private GetOfflinePendingTransactionCountDataResponse GetOfflinePendingTransactionCount(GetOfflinePendingTransactionCountDataRequest request)
 {
     using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request))
     {
         GetOfflinePendingTransactionCountProcedure getOfflinePendingTransactionCountProcedure = new GetOfflinePendingTransactionCountProcedure(request, databaseContext);
         return(getOfflinePendingTransactionCountProcedure.GetPendingTransactionCount());
     }
 }
Ejemplo n.º 23
0
 private static EntityDataServiceResponse <SalesLine> GetSalesLines(GetSalesLinesDataRequest request)
 {
     using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request))
     {
         GetSalesLinesProcedure getSalesLinesProcedure = new GetSalesLinesProcedure(request, databaseContext);
         return(getSalesLinesProcedure.Execute());
     }
 }
 /// <summary>
 /// The data service method to get the shift data.
 /// </summary>
 /// <param name="request">The get shift data request.</param>
 /// <returns>A response.</returns>
 private Response GetShiftData(GetShiftDataDataRequest request)
 {
     using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request))
     {
         GetShiftDataProcedure procedure = new GetShiftDataProcedure(request, databaseContext);
         return(procedure.Execute(request.QueryResultSettings));
     }
 }
            private EntityDataServiceResponse <HardwareStationProfile> GetHardwareStationProfile(GetHardwareStationDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.RequestContext, "request.RequestContext");
                ThrowIf.Null(request.QueryResultSettings, "request.QueryResultSettings");

                ParameterSet parameters = new ParameterSet();
                Tuple <PagedResult <HardwareStationProfile>,
                       ReadOnlyCollection <HardwareConfiguration>,
                       ReadOnlyCollection <HardwareConfiguration>,
                       ReadOnlyCollection <HardwareConfiguration> > dataSets = null;

                parameters[DatabaseAccessor.ChannelIdVariableName] = request.RequestContext.GetPrincipal().ChannelId;

                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext, request.QueryResultSettings))
                {
                    dataSets = databaseContext.ExecuteStoredProcedure <HardwareStationProfile, HardwareConfiguration, HardwareConfiguration, HardwareConfiguration>(GetHardwareStationsSprocName, parameters);
                }

                PagedResult <HardwareStationProfile>       hardwareStationProfiles = dataSets.Item1;
                ReadOnlyCollection <HardwareConfiguration> drawers  = dataSets.Item2;
                ReadOnlyCollection <HardwareConfiguration> printers = dataSets.Item3;
                ReadOnlyCollection <HardwareConfiguration> pinpads  = dataSets.Item4;

                foreach (var hardwareStationProfile in hardwareStationProfiles.Results)
                {
                    if (hardwareStationProfile != null)
                    {
                        hardwareStationProfile.HardwareConfigurations = new HardwareConfigurations();
                        if (drawers != null)
                        {
                            hardwareStationProfile.HardwareConfigurations.CashDrawerConfigurations.AddRange(
                                from d in drawers
                                where d.HardwareStationRecordId == hardwareStationProfile.RecordId && !string.IsNullOrEmpty(d.DeviceName)
                                select d);
                        }

                        if (printers != null)
                        {
                            hardwareStationProfile.HardwareConfigurations.PrinterConfigurations.AddRange(
                                from p in printers
                                where p.HardwareStationRecordId == hardwareStationProfile.RecordId && !string.IsNullOrEmpty(p.DeviceName)
                                select p);
                        }

                        if (pinpads != null)
                        {
                            hardwareStationProfile.HardwareConfigurations.PinPadConfiguration =
                                (from p in pinpads
                                 where p.HardwareStationRecordId == hardwareStationProfile.RecordId && !string.IsNullOrEmpty(p.DeviceName)
                                 select p).SingleOrDefault();
                        }
                    }
                }

                return(new EntityDataServiceResponse <HardwareStationProfile>(hardwareStationProfiles));
            }
Ejemplo n.º 26
0
            private ValidateAddressDataResponse ValidateAddress(ValidateAddressDataRequest request)
            {
                ThrowIf.Null(request.Address, "address");

                if (string.IsNullOrWhiteSpace(request.Address.ThreeLetterISORegionName))
                {
                    return(CreateFailedValidateAddressDataResponse(DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_InvalidCountryRegion, AddressServiceConstants.ThreeLetterISORegionName));
                }

                Address address = request.Address;

                ParameterSet parameters = new ParameterSet();

                parameters[AddressServiceConstants.CountryRegionId] = address.ThreeLetterISORegionName;

                if (!string.IsNullOrWhiteSpace(address.State))
                {
                    parameters[AddressServiceConstants.StateProvinceId] = address.State;
                }

                if (!string.IsNullOrWhiteSpace(address.County))
                {
                    parameters[AddressServiceConstants.CountyId] = address.County;
                }

                if (!string.IsNullOrWhiteSpace(address.City))
                {
                    parameters[AddressServiceConstants.CityComponentName] = address.City;
                }

                if (!string.IsNullOrWhiteSpace(address.DistrictName))
                {
                    parameters[AddressServiceConstants.DistrictId] = address.DistrictName;
                }

                if (!string.IsNullOrWhiteSpace(address.ZipCode))
                {
                    parameters[AddressServiceConstants.ZipPostalCodeComponentName] = address.ZipCode;
                }

                int result;

                using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    result = sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(ValidateAddressSprocName, parameters);
                }

                if (result == 0)
                {
                    return(new ValidateAddressDataResponse(true));
                }

                Tuple <DataValidationErrors, string> faultAddressComponent = HandleNonZeroResult(result);

                return(CreateFailedValidateAddressDataResponse(faultAddressComponent.Item1, faultAddressComponent.Item2));
            }
            /// <summary>
            /// Converts shift To table variable parameters and calls stored procedure.
            /// </summary>
            /// <param name="storedProcedureName">The stored procedure name.</param>
            /// <param name="request">The create shift data request.</param>
            /// <param name="isShiftStagingTableRow">A boolean value indicating if the row is from shift staging table or Pos batch table.</param>
            private void ConvertShiftToTableVariableParametersAndCallStoredProcedure(string storedProcedureName, ShiftDataRequest request, bool isShiftStagingTableRow = true)
            {
                string inventLocationDataAreaId = request.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;
                Shift  shift      = request.Shift;
                var    parameters = new ParameterSet();

                using (DataTable shiftTable = new DataTable(ShiftTableTypeName))
                    using (DataTable shiftTenderLineTable = new DataTable(ShiftTenderLineTableTypeName))
                        using (DataTable shiftAccountLineTable = new DataTable(ShiftAccountLineTableTypeName))
                        {
                            this.SetShiftTableTypeSchema(shiftTable);
                            shiftTable.Rows.Add(this.ConvertToShiftDataRow(shiftTable, shift, inventLocationDataAreaId, isShiftStagingTableRow));
                            parameters[ShiftTableTypeVariableName] = shiftTable;

                            if (shift.Status == ShiftStatus.Closed)
                            {
                                // Only closed shift contains tenderline information.
                                this.SetShiftTenderLineTableTypeSchema(shiftTenderLineTable);
                                foreach (DataRow row in this.ConvertToShiftTenderLineDataRows(shiftTenderLineTable, shift, inventLocationDataAreaId))
                                {
                                    shiftTenderLineTable.Rows.Add(row);
                                }

                                parameters[ShiftTenderLineTableTypeVariableName] = shiftTenderLineTable;

                                // Insert account (income /expense) lines
                                this.SetShiftAccountLineTableTypeSchema(shiftAccountLineTable);
                                foreach (DataRow row in this.ConvertToShiftAccountLineDataRows(shiftAccountLineTable, shift, inventLocationDataAreaId))
                                {
                                    shiftAccountLineTable.Rows.Add(row);
                                }

                                parameters[ShiftAccountLineTableTypeVariableName] = shiftAccountLineTable;
                            }

                            var inputOutputParameters = new ParameterSet();
                            inputOutputParameters[RowVersionViarableName] = shift.RowVersion;
                            int errorCode;

                            using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                            {
                                errorCode = sqlServerDatabaseContext.ExecuteStoredProcedureScalar(storedProcedureName, parameters, inputOutputParameters);
                            }

                            if (errorCode != (int)DatabaseErrorCodes.Success)
                            {
                                throw new StorageException(
                                          StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError,
                                          errorCode,
                                          string.Format("Unable to execute the stored procedure {0}.", storedProcedureName));
                            }

                            shift.RowVersion = inputOutputParameters[RowVersionViarableName] as byte[];
                        }
            }
Ejemplo n.º 28
0
            /// <summary>
            /// The data service method to execute the data manager to get the device configuration.
            /// </summary>
            /// <param name="request">The data service request.</param>
            /// <returns>The data service response.</returns>
            private SingleEntityDataServiceResponse <DeviceConfiguration> GetDeviceConfiguration(GetDeviceConfigurationDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.RequestContext, "request.RequestContext");
                ThrowIf.Null(request.QueryResultSettings, "request.QueryResultSettings");

                ICommercePrincipal principal = request.RequestContext.GetPrincipal();

                if (principal.IsChannelAgnostic || principal.IsTerminalAgnostic || string.IsNullOrWhiteSpace(principal.DeviceNumber))
                {
                    throw new InvalidOperationException("Current request context is not associated to a device.");
                }

                Terminal terminal = request.RequestContext.GetTerminal();

                ParameterSet parameters = new ParameterSet();
                Tuple <PagedResult <DeviceConfiguration>,
                       ReadOnlyCollection <HardwareConfiguration>,
                       ReadOnlyCollection <HardwareConfiguration>,
                       ReadOnlyCollection <HardwareConfiguration> > dataSets = null;

                parameters[DatabaseAccessor.ChannelIdVariableName] = terminal.ChannelId;
                parameters[TerminalIdVariableName]    = terminal.TerminalId;
                parameters[IncludeImagesVariableName] = request.IncludeImages;

                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext, request.QueryResultSettings))
                {
                    dataSets = databaseContext.ExecuteStoredProcedure <DeviceConfiguration, HardwareConfiguration, HardwareConfiguration, HardwareConfiguration>(GetDeviceConfigurationSprocName, parameters);
                }

                DeviceConfiguration deviceConfiguration             = dataSets.Item1.SingleOrDefault();
                ReadOnlyCollection <HardwareConfiguration> drawers  = dataSets.Item2;
                ReadOnlyCollection <HardwareConfiguration> printers = dataSets.Item3;
                ReadOnlyCollection <HardwareConfiguration> pinpads  = dataSets.Item4;

                if (deviceConfiguration != null)
                {
                    deviceConfiguration.HardwareConfigurations = new HardwareConfigurations();
                    deviceConfiguration.HardwareConfigurations.CashDrawerConfigurations.AddRange(drawers);
                    deviceConfiguration.HardwareConfigurations.PrinterConfigurations.AddRange(printers);
                    deviceConfiguration.HardwareConfigurations.PinPadConfiguration = pinpads.SingleOrDefault();
                }

                GetDeviceDataRequest getDeviceRequest = new GetDeviceDataRequest(principal.DeviceNumber);
                Device device = request.RequestContext.Execute <SingleEntityDataServiceResponse <Device> >(getDeviceRequest).Entity;

                if (deviceConfiguration != null && device != null)
                {
                    deviceConfiguration.UseInMemoryDeviceDataStorage = device.UseInMemoryDeviceDataStorage;
                }

                return(new SingleEntityDataServiceResponse <DeviceConfiguration>(deviceConfiguration));
            }
Ejemplo n.º 29
0
            /// <summary>
            /// Delete user credentials associated to the <paramref name="request"/>.
            /// </summary>
            /// <param name="request">The data request.</param>
            /// <returns>A void service response.</returns>
            private NullResponse DeleteUserCredentials(DeleteUserCredentialsDataRequest request)
            {
                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters["@nvc_staffId"]   = request.UserId;
                    parameters["@nvc_grantType"] = request.GrantType;

                    databaseContext.ExecuteStoredProcedureNonQuery(DeleteUserCredentialsSprocName, parameters);
                }

                return(new NullResponse());
            }
Ejemplo n.º 30
0
            /// <summary>
            /// Save non sales transaction.
            /// </summary>
            /// <param name="request">Non sales transaction data service request.</param>
            /// <returns>A SingleEntityDataServiceResponse containing the saved NonSalesTransaction object.</returns>
            private SingleEntityDataServiceResponse <NonSalesTransaction> SaveNonSalesTransaction(SaveNonSalesTransactionDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.NonSalesTransaction, "request.NonSalesTransaction");

                var nonSalesTransaction = request.NonSalesTransaction;

                NonSalesTransaction savedTransaction = null;

                using (var transactionTable = new DataTable(RetailTransactionTableType))
                    using (var paymentTable = new DataTable(RetailTransactionPaymentTransTableType))
                        using (var reasonCodeTable = new DataTable(RetailTransactionInfoCodeTransTableType))
                        {
                            TransactionLog transaction = this.Convert(nonSalesTransaction);

                            RetailTransactionTableSchema.PopulateSchema(transactionTable);

                            TransactionLogDataManager.FillData(request.RequestContext, transaction, transactionTable);

                            var parameters = new ParameterSet();
                            parameters[DatabaseAccessor.ChannelIdVariableName] = request.RequestContext.GetPrincipal().ChannelId;
                            parameters["@tvp_Transaction"] = transactionTable;

                            if (!nonSalesTransaction.TransactionType.Equals(Microsoft.Dynamics.Commerce.Runtime.DataModel.TransactionType.OpenDrawer))
                            {
                                RetailTransactionPaymentSchema.PopulatePaymentSchema(paymentTable);
                                this.FillPaymentDataTable(nonSalesTransaction.Id, nonSalesTransaction, paymentTable, request.RequestContext);
                                parameters["@tvp_PaymentTrans"] = paymentTable;
                            }
                            else
                            {
                                RetailTransactionPaymentSchema.PopulateReasonCodeSchema(reasonCodeTable);                                    // Populate reason code schema
                                this.FillReasonCodeLines(transaction.Id, nonSalesTransaction, reasonCodeTable, -1m, request.RequestContext); // Fill captured reason code details
                                parameters["@tvp_ReasoncodeLine"] = reasonCodeTable;                                                         // Reason code parameter for [Open Drawer] store operation
                            }

                            int errorCode;
                            using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                            {
                                savedTransaction = sqlServerDatabaseContext.ExecuteStoredProcedure <NonSalesTransaction>(InsertNonSaleTenderSprocName, parameters, out errorCode).FirstOrDefault();
                            }

                            if (errorCode != (int)DatabaseErrorCodes.Success)
                            {
                                throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError, errorCode, "Unable to save non sale tender operation.");
                            }
                        }

                return(new SingleEntityDataServiceResponse <NonSalesTransaction>(savedTransaction));
            }