Beispiel #1
0
 public void UpdatePlayer(Player player)
 {
     ThrowIf.ArgumentIsNull(player);
     using (var connection = connectionFactory.Connect())
     {
         string            sql = GetUpdateStatement();
         DynamicParameters p   = SetupUpdateParameters(player);
         connection.Open();
         connection.Execute(sql, p);
     }
     memberQuery.UpdateCache();
 }
Beispiel #2
0
        // Given three images, return an image that highlights the differences in common betwen the main image and the first image
        // and the main image and a second image.
        public static unsafe WriteableBitmap CombinedDifference(this WriteableBitmap unaltered, WriteableBitmap previous, WriteableBitmap next, byte threshold)
        {
            // Check the arguments for null
            ThrowIf.IsNullArgument(unaltered, nameof(unaltered));
            ThrowIf.IsNullArgument(previous, nameof(previous));
            ThrowIf.IsNullArgument(next, nameof(next));

            if (WriteableBitmapExtensions.BitmapsMismatched(unaltered, previous) ||
                WriteableBitmapExtensions.BitmapsMismatched(unaltered, next))
            {
                return(null);
            }

            WriteableBitmapExtensions.GetColorOffsets(unaltered, out int blueOffset, out int greenOffset, out int redOffset);

            int   totalPixels      = unaltered.PixelWidth * unaltered.PixelHeight;
            int   pixelSizeInBytes = unaltered.Format.BitsPerPixel / 8;
            byte *unalteredIndex   = (byte *)unaltered.BackBuffer.ToPointer();
            byte *previousIndex    = (byte *)previous.BackBuffer.ToPointer();
            byte *nextIndex        = (byte *)next.BackBuffer.ToPointer();

            byte[] differencePixels = new byte[totalPixels * pixelSizeInBytes];
            int    differenceIndex  = 0;

            for (int pixel = 0; pixel < totalPixels; ++pixel)
            {
                byte b1 = (byte)Math.Abs(*(unalteredIndex + blueOffset) - *(previousIndex + blueOffset));
                byte g1 = (byte)Math.Abs(*(unalteredIndex + greenOffset) - *(previousIndex + greenOffset));
                byte r1 = (byte)Math.Abs(*(unalteredIndex + redOffset) - *(previousIndex + redOffset));

                byte b2 = (byte)Math.Abs(*(unalteredIndex + blueOffset) - *(nextIndex + blueOffset));
                byte g2 = (byte)Math.Abs(*(unalteredIndex + greenOffset) - *(nextIndex + greenOffset));
                byte r2 = (byte)Math.Abs(*(unalteredIndex + redOffset) - *(nextIndex + redOffset));

                byte b = WriteableBitmapExtensions.DifferenceIfAboveThreshold(threshold, b1, b2);
                byte g = WriteableBitmapExtensions.DifferenceIfAboveThreshold(threshold, g1, g2);
                byte r = WriteableBitmapExtensions.DifferenceIfAboveThreshold(threshold, r1, r2);

                byte averageDifference = (byte)((b + g + r) / 3);
                differencePixels[differenceIndex + blueOffset]  = averageDifference;
                differencePixels[differenceIndex + greenOffset] = averageDifference;
                differencePixels[differenceIndex + redOffset]   = averageDifference;

                unalteredIndex  += pixelSizeInBytes;
                previousIndex   += pixelSizeInBytes;
                nextIndex       += pixelSizeInBytes;
                differenceIndex += pixelSizeInBytes;
            }

            WriteableBitmap difference = new WriteableBitmap(BitmapSource.Create(unaltered.PixelWidth, unaltered.PixelHeight, unaltered.DpiX, unaltered.DpiY, unaltered.Format, unaltered.Palette, differencePixels, unaltered.BackBufferStride));

            return(difference);
        }
        public DateTimeRereadFromFiles(Window owner, FileDatabase fileDatabase) : base(owner)
        {
            // Check the arguments for null
            ThrowIf.IsNullArgument(fileDatabase, nameof(fileDatabase));

            this.InitializeComponent();

            this.fileDatabase = fileDatabase;

            // Tracks whether any changes to the data or database are made
            this.IsAnyDataUpdated = false;
        }
Beispiel #4
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));
            }
        public UpdateApplicationRequest(
            IFabricClient fabricClient,
            ApplicationUpdateDescription updateDescription,
            TimeSpan timeout)
            : base(fabricClient, timeout)
        {
            ThrowIf.Null(updateDescription, "ApplicationUpdateDescription");

            this.UpdateDescription = updateDescription;

            this.ConfigureErrorCodes();
        }
Beispiel #6
0
            /// <summary>
            /// Processes the GetXZReportReceiptRequest to return the X or Z report receipts. The request should not be null.
            /// </summary>
            /// <param name="request">The request parameter.</param>
            /// <returns>The GetReceiptResponse.</returns>
            protected override GetReceiptResponse Process(GetXAndZReportReceiptRequest request)
            {
                ThrowIf.Null(request, "request");

                var getReceiptServiceRequest  = this.CreateXZReportReceiptServiceRequest(request);
                var getReceiptServiceResponse = this.Context.Execute <GetReceiptServiceResponse>(getReceiptServiceRequest);

                // Save the transaction log for printing X or X report
                this.LogTransaction(request);

                return(new GetReceiptResponse(getReceiptServiceResponse.Receipts));
            }
Beispiel #7
0
        public static T UiThread <T>(this Control control, Func <T> func)
        {
            ThrowIf.Null(control, nameof(control));
            ThrowIf.Null(func, nameof(func));

            if (control.InvokeRequired)
            {
                return((T)control.Invoke(func));
            }

            return(func());
        }
Beispiel #8
0
            /// <summary>
            /// Creates the mapped exception for <see cref="Exception"/> returned during invoking realtime transaction service method.
            /// </summary>
            /// <param name="methodName">The method name.</param>
            /// <param name="exception">The exception.</param>
            /// <param name="errorResourceId">The <see cref="CommunicationErrors"/> enumeration.</param>
            /// <param name="errorMessage">The error message in the communication exception.</param>
            /// <returns>The <see cref="CommunicationException"/>.</returns>
            public static CRT.CommunicationException CreateCommunicationException(string methodName, Exception exception, CommunicationErrors errorResourceId, string errorMessage = "")
            {
                ThrowIf.Null(methodName, "methodName");
                ThrowIf.Null(exception, "exception");

                errorMessage = string.IsNullOrWhiteSpace(errorMessage) ? string.Format("Exception while calling invoke method {0}: {1}", methodName, exception.Message) : errorMessage;

                return(new CRT.CommunicationException(
                           errorResourceId,
                           exception,
                           errorMessage));
            }
            /// <summary>
            /// Adds loyalty card tier table schema into the data table.
            /// </summary>
            /// <param name="table">The data table.</param>
            private static void AddLoyaltyCardTierTableTypeSchema(DataTable table)
            {
                ThrowIf.Null(table, "table");

                // NOTE: The order of colums here MUST match the @TVP_LOYALTYCARDTIERTABLETYPE.
                table.Columns.Add(LoyaltySqlServerDataService.RecIdColumn, typeof(long));
                table.Columns.Add(LoyaltySqlServerDataService.AffiliationColumn, typeof(long));
                table.Columns.Add(LoyaltySqlServerDataService.LoyaltyCardColumn, typeof(long));
                table.Columns.Add(LoyaltySqlServerDataService.LoyaltyTierColumn, typeof(long));
                table.Columns.Add(LoyaltySqlServerDataService.ValidFromColumn, typeof(DateTime));
                table.Columns.Add(LoyaltySqlServerDataService.ValidToColumn, typeof(DateTime));
            }
        public PatientController
        (
            IPatientService patientService,
            ILogger <PatientController> logger
        )
        {
            ThrowIf.Null(patientService, nameof(patientService));
            ThrowIf.Null(logger, nameof(logger));

            _patientService = patientService;
            _logger         = logger;
        }
Beispiel #11
0
            /// <summary>
            /// Upload an offline sales order.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>The response.</returns>
            protected override UploadOrderResponse Process(UploadOrderRequest request)
            {
                ThrowIf.Null(request, "request");

                request.Order.ValidateSalesOrder(this.Context);

                var saveTransactionRequest = new SaveSalesTransactionDataRequest(request.Order);

                this.Context.Runtime.Execute <NullResponse>(saveTransactionRequest, this.Context);

                return(new UploadOrderResponse());
            }
        public StartNodeTransitionRequest(IFabricClient fabricClient, NodeTransitionDescription description, TimeSpan timeout)
            : base(fabricClient, timeout)
        {
            ThrowIf.Null(description, "description");

            this.Description = description;

            this.RetryErrorCodes.Add((uint)NativeTypes.FABRIC_ERROR_CODE.FABRIC_E_NOT_READY);
            this.RetryErrorCodes.Add((uint)NativeTypes.FABRIC_ERROR_CODE.FABRIC_E_RECONFIGURATION_PENDING);

            this.SucceedErrorCodes.Add((uint)NativeTypes.FABRIC_ERROR_CODE.FABRIC_E_TEST_COMMAND_OPERATION_ID_ALREADY_EXISTS);
        }
Beispiel #13
0
            /// <summary>
            /// Executes the workflow for a get price check for a product.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>The response.</returns>
            protected override PriceCheckResponse Process(PriceCheckRequest request)
            {
                ThrowIf.Null(request, "request");

                ItemBarcode itemBarcode = null;

                if (string.IsNullOrEmpty(request.Barcode) && string.IsNullOrEmpty(request.ItemId))
                {
                    throw new DataValidationException(DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_ItemIdBarcodeMissing, "Either an item identifier or barcode is required.");
                }

                if (string.IsNullOrEmpty(request.ItemId))
                {
                    GetProductBarcodeDataRequest dataRequest = new GetProductBarcodeDataRequest(request.Barcode);
                    itemBarcode = this.Context.Runtime.Execute <GetProductBarcodeDataResponse>(dataRequest, this.Context).Barcode;
                }

                SalesTransaction salesTransaction = new SalesTransaction()
                {
                    Id         = Guid.NewGuid().ToString(),
                    CustomerId = request.CustomerAccountNumber,
                };

                SalesLine salesLine = new SalesLine()
                {
                    ItemId = request.ItemId,
                    InventoryDimensionId    = request.InventoryDimensionId ?? itemBarcode.InventoryDimensionId,
                    SalesOrderUnitOfMeasure = request.UnitOfMeasureSymbol ?? itemBarcode.UnitId,
                    Quantity = 1m,
                    LineId   = Guid.NewGuid().ToString()
                };

                salesTransaction.SalesLines.Add(salesLine);

                GetIndependentPriceDiscountServiceRequest priceRequest = new GetIndependentPriceDiscountServiceRequest(salesTransaction);

                GetPriceServiceResponse pricingServiceResponse = this.Context.Execute <GetPriceServiceResponse>(priceRequest);

                SalesLine resultLine = pricingServiceResponse.Transaction.SalesLines[0];

                ProductPrice productPrice = GetProductPrice(
                    resultLine.ItemId,
                    resultLine.InventoryDimensionId,
                    resultLine.BasePrice,
                    resultLine.TotalAmount,
                    this.Context.GetChannelConfiguration().Currency);

                var productPrices = new List <ProductPrice> {
                    productPrice
                };

                return(new PriceCheckResponse(productPrices.AsPagedResult()));
            }
            /// <summary>
            /// Register the time for employee break.
            /// </summary>
            /// <param name="context">The request context.</param>
            /// <param name="jobId">The job identifier.</param>
            /// <returns>Returns the activity DateTimeOffset in channel local time zone.</returns>
            public static DateTimeOffset RegisterEmployeeBreak(RequestContext context, string jobId)
            {
                ThrowIf.Null(context, "context");
                ThrowIf.NullOrWhiteSpace(jobId, "jobId");

                var request = new RegisterEmployeeBreakRealtimeRequest(
                    context.GetPrincipal().UserId,
                    context.GetTerminal().TerminalId,
                    jobId);

                return(context.Execute <SingleEntityDataServiceResponse <DateTimeOffset> >(request).Entity);
            }
Beispiel #15
0
        protected static CommandDefinition CreateCommand(string commandText, object?parameters, IDbTransaction?transaction, CancellationToken cancellationToken)
        {
            ThrowIf.Null(commandText, nameof(commandText));

            return(new CommandDefinition
                   (
                       commandText: commandText,
                       parameters: parameters,
                       transaction: transaction,
                       cancellationToken: cancellationToken
                   ));
        }
Beispiel #16
0
        public static DbTempTableColumn <TRow> From <TValue>(string name, string dbType, Func <TRow, TValue> getValue)
        {
            ThrowIf.NullOrWhiteSpace(name, nameof(name));
            ThrowIf.NullOrWhiteSpace(dbType, nameof(dbType));
            ThrowIf.Null(getValue, nameof(getValue));

            var type = typeof(TValue);

            object?GetBoxedValue(TRow obj) => getValue(obj);

            return(new DbTempTableColumn <TRow>(name, dbType, type, GetBoxedValue));
        }
        /// <summary>
        /// Construct the Payment Device class and open the connection from it.
        /// </summary>
        /// <returns>The response.</returns>
        /// <param name="request">Open payment terminal device request.</param>
        private NullResponse Open(OpenPaymentTerminalDeviceRequest request)
        {
            ThrowIf.Null(request, nameof(request));

            // Open the device for payments
            Utilities.WaitAsyncTask(() => Task.Run(async() =>
            {
                await this.OpenAsync(request.DeviceName, request.TerminalSettings, request.DeviceConfig).ConfigureAwait(false);
            }));

            return(new NullResponse());
        }
Beispiel #18
0
        public DbTempTableColumn(string name, string dbType, Type type, Func <TRow, object?> getValue)
        {
            ThrowIf.NullOrWhiteSpace(name, nameof(name));
            ThrowIf.NullOrWhiteSpace(dbType, nameof(dbType));
            ThrowIf.Null(type, nameof(type));
            ThrowIf.Null(getValue, nameof(getValue));

            Name     = name;
            DbType   = dbType;
            Type     = type;
            GetValue = getValue;
        }
 /// <summary>
 /// Instantiates ProxyConnectionInfo with certificate authentication using a certificate retrieved from keyvault
 /// </summary>
 /// <param name="endpoint">Proxy Endpoint</param>
 /// <param name="config">Configuration root for initialization</param>
 /// <param name="vaultName">Key vault name</param>
 public ProxyConnectionInfo(
     string endpoint,
     KeyVaultConfiguration config,
     string vaultName
     ) : this(
         endpoint,
         AuthenticationType.CertificateFromKeyVault
         )
 {
     Vault          = new AzureSecretVault(config);
     CertIdentifier = ThrowIf.NullOrWhiteSpace(vaultName, nameof(vaultName));
 }
Beispiel #20
0
        /// <summary>
        /// Simple constructor with only the required domain and api key options
        /// </summary>
        /// <param name="domain">The Mailgun domain to use</param>
        /// <param name="apikey">The Mailgun Apikey to use</param>
        /// <param name="from">The from address to send messages from</param>
        /// <param name="baseUrlOverride"> Override the mailgun base URL</param>
        public MailgunMessageService(string domain, string apikey, string from, string baseUrlOverride = null)
        {
            ThrowIf.IsArgumentNull(() => domain);
            ThrowIf.IsArgumentNull(() => apikey);
            ThrowIf.IsArgumentNull(() => from);

            _from = new Recipient {
                Email = from
            };
            _domain         = domain;
            _messageService = new MessageService(apikey, true, baseUrlOverride);
        }
Beispiel #21
0
 public void DeleteCoach(Coach coach)
 {
     ThrowIf.ArgumentIsNull(coach);
     using (var connection = connectionFactory.Connect()) {
         string sql = "UPDATE Coaches SET Deleted=1, DeletedOn=GetDate() WHERE Guid = @CoachGuid";
         var    p   = new DynamicParameters();
         p.Add("@CoachGuid", coach.Guid.ToString());
         connection.Open();
         connection.Execute(sql, p);
     }
     memberQuery.UpdateCache();
 }
Beispiel #22
0
            public ImageQuality(ImageRow image)
            {
                // Check the arguments for null
                ThrowIf.IsNullArgument(image, nameof(image));

                this.Bitmap = null;
                this.DarkPixelRatioFound = 0;
                this.FileName            = image.File;
                this.IsColor             = false;
                this.OldImageQuality     = image.ImageQuality;
                this.NewImageQuality     = null;
            }
Beispiel #23
0
            /// <summary>
            /// Initializes a new instance of the <see cref="IndiaPriceHelper"/> class.
            /// </summary>
            /// <param name="channelConfiguration">The channel configuration.</param>
            /// <param name="pricingDataManager">Pricing data manager.</param>
            /// <param name="transaction">Current transaction.</param>
            /// /// <param name="priceGroup">Customer price group.</param>
            /// <returns>The instance of IndiaPriceHelper.</returns>
            public IndiaPriceHelper(ChannelConfiguration channelConfiguration, IPricingDataAccessor pricingDataManager, SalesTransaction transaction, string priceGroup)
            {
                ThrowIf.Null(channelConfiguration, "channelConfiguration");
                ThrowIf.Null(pricingDataManager, "pricingDataManager");
                ThrowIf.Null(transaction, "transaction");

                this.channelConfiguration = channelConfiguration;
                this.pricingDataManager   = pricingDataManager;
                this.salesTransaction     = transaction;
                this.customerId           = transaction.CustomerId;
                this.priceGroup           = priceGroup;
            }
            /// <summary>
            /// Helper methods to calculates the required reason codes.
            /// </summary>
            /// <param name="requestContext">The request context.</param>
            /// <param name="serviceRequest">The service request.</param>
            /// <exception cref="ConfigurationException">Required Service missing: {0}.</exception>
            private static void CalculateRequiredReasonCodesHelper(RequestContext requestContext, CalculateRequiredReasonCodesServiceRequest serviceRequest)
            {
                ThrowIf.Null(serviceRequest.SalesTransaction, "serviceRequest.SalesTransaction");

                // Reason codes are only calculated for retail stores and carts that are not customer orders.
                if ((requestContext.GetChannelConfiguration().ChannelType == RetailChannelType.RetailStore) &&
                    (serviceRequest.SalesTransaction.CartType != CartType.CustomerOrder))
                {
                    var serviceResponse = requestContext.Execute <CalculateRequiredReasonCodesServiceResponse>(serviceRequest);
                    ReasonCodesWorkflowHelper.ThrowIfRequiredReasonCodesMissing(serviceResponse);
                }
            }
            /// <summary>
            /// Resets the password of the user <param name="userId" />.
            /// </summary>
            /// <param name="userId">The id of the user having the password changed.</param>
            /// <param name="newPassword">The newPassword.</param>
            /// <param name="mustChangePasswordAtNextLogOn">Whether the password needs to be changed at the next logon.</param>
            /// <returns>A Task.</returns>
            internal override async Task ResetPassword(string userId, string newPassword, bool mustChangePasswordAtNextLogOn)
            {
                ThrowIf.NullOrWhiteSpace(userId, "userId");
                ThrowIf.NullOrWhiteSpace(newPassword, "newPassword");

                StringBuilder data = this.CreateResetPasswordRequest(userId, newPassword, mustChangePasswordAtNextLogOn);
                const string  ResetPasswordOperation = "ResetPassword";

                using (var response = await this.SendServerRequest(data, HttpMethod.Post, ResetPasswordOperation, JsonContentType, true))
                {
                }
            }
Beispiel #26
0
        public Startup(IHostingEnvironment env)
        {
            const string KUBERNETES_STACK = "K8SSTACK";
            const string STAGING_DB_CONNECTION_STRING_KEY = "incidentStaging";

            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            if (env.IsDevelopment())
            {
                builder.AddUserSecrets <Startup>();
            }
            _configuration        = builder.Build();
            _gatewayConfiguration = _configuration.Get <GatewayConfiguration>();

            if (env.IsStaging())
            {
                _gatewayConfiguration.GatewayDatabaseConnectionString = _configuration.GetConnectionString(STAGING_DB_CONNECTION_STRING_KEY);
            }
            else if (env.IsEnvironment(KUBERNETES_STACK))
            {
                ThrowIf.NullOrWhiteSpace(_gatewayConfiguration.ClientSecret, nameof(_gatewayConfiguration.ClientSecret));
                ThrowIf.NullOrWhiteSpace(_gatewayConfiguration.KeyVaultAccessor.VaultName,
                                         nameof(_gatewayConfiguration.KeyVaultAccessor.VaultName));
                ThrowIf.NullOrWhiteSpace(_gatewayConfiguration.KeyVaultAccessor.GatewayDatabaseConnectionStringName,
                                         nameof(_gatewayConfiguration.KeyVaultAccessor.GatewayDatabaseConnectionStringName));
                ThrowIf.NullOrWhiteSpace(_gatewayConfiguration.KeyVaultAccessor.GatewayRedisPasswordName,
                                         nameof(_gatewayConfiguration.KeyVaultAccessor.GatewayRedisPasswordName));

                var keyVaultUrl = String.Format(
                    CultureInfo.InvariantCulture,
                    "https://{0}.vault.azure.net/",
                    _gatewayConfiguration.KeyVaultAccessor.VaultName);
                builder.AddAzureKeyVault(keyVaultUrl, _gatewayConfiguration.ClientId, _gatewayConfiguration.ClientSecret);
                _configuration = builder.Build();

                var accessor         = _gatewayConfiguration.KeyVaultAccessor;
                var connectionString = _configuration[accessor.GatewayDatabaseConnectionStringName];
                ThrowIf.NullOrWhiteSpace(connectionString, accessor.GatewayDatabaseConnectionStringName);
                _gatewayConfiguration.GatewayDatabaseConnectionString = connectionString;

                var redisPassword = _configuration[accessor.GatewayRedisPasswordName];
                ThrowIf.NullOrWhiteSpace(redisPassword, accessor.GatewayRedisPasswordName);
                _gatewayConfiguration.Redis.Password = redisPassword;
            }
            var appInsightsTask = _gatewayConfiguration.InitializeApplicationInsights();

            appInsightsTask.Wait();
            _env = env;
        }
Beispiel #27
0
        public CoachService(IClubQuery clubQuery, IMemberQuery memberQuery, ICoachRepository coachRepository, IValidator <CoachRequest> validator, IIdentityManager identityManager)
        {
            ThrowIf.ArgumentIsNull(clubQuery);
            ThrowIf.ArgumentIsNull(coachRepository);
            ThrowIf.ArgumentIsNull(validator);

            this.clubQuery       = clubQuery;
            this.memberQuery     = memberQuery;
            this.coachRepository = coachRepository;
            this.validator       = validator;
            this.identityManager = identityManager;
        }
 public PasswordVerificationResult VerifyHashedPassword(string hashedPassword, string providedPassword)
 {
     // Throw an error if any of our passwords are null
     ThrowIf.ArgumentIsNull(() => hashedPassword, () => providedPassword);
     // Just check if the two values are the same
     if (hashedPassword.Equals(this.HashPassword(providedPassword)))
     {
         return(PasswordVerificationResult.Success);
     }
     // Fallback
     return(PasswordVerificationResult.Failed);
 }
            /// <summary>
            /// Voids active gift card lines on the transaction.
            /// </summary>
            /// <param name="context">The context.</param>
            /// <param name="salesTransaction">The sales transaction.</param>
            internal static void VoidGiftCardSalesLines(RequestContext context, SalesTransaction salesTransaction)
            {
                ThrowIf.Null(context, "context");
                ThrowIf.Null(salesTransaction, "salesTransaction");

                IEnumerable <SalesLine> activeGiftCardLines = salesTransaction.SalesLines.Where(l => l.IsGiftCardLine && !l.IsVoided);

                foreach (SalesLine line in activeGiftCardLines)
                {
                    GiftCardWorkflowHelper.VoidGiftCardOperation(context, salesTransaction, line.GiftCardId, line.GiftCardCurrencyCode, line.GiftCardOperation, line.TotalAmount);
                }
            }
Beispiel #30
0
 public void DeletePlayer(Player player)
 {
     ThrowIf.ArgumentIsNull(player);
     using (var connection = connectionFactory.Connect()) {
         string sql = "UPDATE PLAYERS SET Deleted=1, DeletedOn=GetDate() WHERE Guid = @PlayerGuid";
         var    p   = new DynamicParameters();
         p.Add("@PlayerGuid", player.Guid.ToString());
         connection.Open();
         connection.Execute(sql, p);
     }
     memberQuery.UpdateCache();
 }