Example #1
0
 private void CompleteSale(BottleReturnSaleModel sale)
 {
     Sale = sale;
     CompleteSale();
     CacheBusinessLogic.FramePriorSwitchUserNavigation = string.Empty;
     CacheBusinessLogic.AuthKey = CacheBusinessLogic.PreviousAuthKey;
     MessengerInstance.Send(false, "LoadAllPolicies");
 }
Example #2
0
 public void ReInitialize()
 {
     IsPrintOn             = false;
     IsCompleteSaleEnabled = false;
     AmountToDisplay       = string.Empty;
     Sale = new BottleReturnSaleModel();
     LoadBottlePages();
 }
Example #3
0
 private void SendToVoidSaleOnSwitchUser(Reasons reasons)
 {
     _fuelPrices              = null;
     _bottleReturnSale        = null;
     _isVoidSaleToBeCompleted = true;
     _lineNumberToBeDeleted   = 0;
     _pumpId            = 0;
     _setPostPayMessage = null;
 }
Example #4
0
 private void SendToDeleteSaleLineOnSwitchUser(int saleLine)
 {
     _fuelPrices              = null;
     _bottleReturnSale        = null;
     _isVoidSaleToBeCompleted = false;
     _lineNumberToBeDeleted   = saleLine;
     _pumpId            = 0;
     _setPostPayMessage = null;
 }
Example #5
0
 private void SaveFuelPrices(SaveFuelPricesMessage message)
 {
     _fuelPrices              = message?.FuelPrices;
     _bottleReturnSale        = null;
     _isVoidSaleToBeCompleted = false;
     _lineNumberToBeDeleted   = 0;
     _pumpId            = 0;
     _setPostPayMessage = null;
 }
Example #6
0
 private void AddManualFuel(AddManualFuelMessage obj)
 {
     _bottleReturnSale        = null;
     _isVoidSaleToBeCompleted = false;
     _lineNumberToBeDeleted   = 0;
     _fuelPrices        = null;
     _pumpId            = obj.PumpId;
     _setPostPayMessage = null;
 }
Example #7
0
 private void SetPostPay(SetPostPayMessage obj)
 {
     _setPostPayMessage       = obj;
     _bottleReturnSale        = null;
     _isVoidSaleToBeCompleted = false;
     _lineNumberToBeDeleted   = 0;
     _fuelPrices = null;
     _pumpId     = 0;
 }
Example #8
0
 private void SendToBottleReturnOnSaleComplete(BottleReturnSaleModel sale)
 {
     // TODO: Ipsit - Not the proper way of injecting the Bottle return dependency
     // in the code for messenging
     _bottleReturnSale        = sale;
     _isVoidSaleToBeCompleted = false;
     _lineNumberToBeDeleted   = 0;
     _fuelPrices        = null;
     _pumpId            = 0;
     _setPostPayMessage = null;
 }
Example #9
0
        /// <summary>
        /// Method to switch user
        /// </summary>
        /// <returns></returns>
        private async Task SwitchUser()
        {
            var startTime = DateTime.Now;

            IsSwitchUserStarted = true;
            SwitchUserStartTime = DateTime.Now;
            try
            {
                var flag = IsSwitchUserInitiatedForUnathorizedAccess();

                var response = await _logoutBussinesslogic.SwitchUserAsync(UserName, Password, flag);

                _invalidLoginAttempts = 0;
                // TODO: Move code of saving auth key to BL

                // TODO: If user closes without Switch user then it will create issue
                CacheBusinessLogic.AuthKey = response;

                switch (CacheBusinessLogic.FramePriorSwitchUserNavigation)
                {
                case "Reports":
                case "PaymentByFleet":
                case "PaymentByAccount":
                case "SwitchUserToCashDraw":
                    NavigateService.Instance.RedirectToHome();
                    MessengerInstance.Send(new CloseKeyboardMessage());
                    break;

                case "PerformManualSale":
                    MessengerInstance.Send(false, "LoadAllPolicies");
                    await Task.Delay(1000);

                    NavigateService.Instance.RedirectToHome();
                    NavigateService.Instance.NavigateToManualFuelSale();
                    MessengerInstance.Send(new FuelManualPumpMessage
                    {
                        PumpId = _pumpId
                    });
                    break;

                default:
                {
                    MessengerInstance.Send(false, "LoadAllPolicies");
                    if (_lineNumberToBeDeleted != 0)
                    {
                        MessengerInstance.Send(_lineNumberToBeDeleted, "CompleteDeleteSaleLine");
                        _lineNumberToBeDeleted = 0;
                    }
                    else if (_bottleReturnSale != null)
                    {
                        MessengerInstance.Send(_bottleReturnSale, "CompleteBottleReturn");
                        _bottleReturnSale = null;
                    }
                    else if (_isVoidSaleToBeCompleted)
                    {
                        MessengerInstance.Send(_isVoidSaleToBeCompleted, "CompleteVoidSale");
                        _isVoidSaleToBeCompleted = false;
                    }
                    else if (_fuelPrices != null)
                    {
                        MessengerInstance.Send(_fuelPrices);
                        _fuelPrices = null;
                    }
                    else if (_setPostPayMessage != null)
                    {
                        MessengerInstance.Send(_setPostPayMessage.Value, "SetPostPay");
                        _setPostPayMessage = null;
                    }
                }
                    NavigateService.Instance.RedirectToHome();
                    MessengerInstance.Send(new CloseKeyboardMessage());
                    break;
                }
            }
            catch (ApiDataException ex)
            {
                if (ex.Message.Contains("Invalid  Password") ||
                    ex.Message.Contains("No Such User"))
                {
                    if (++_invalidLoginAttempts == MaxInvalidAttemps)
                    {
                        ShowNotification(ApplicationConstants.MaxLoginAttemptsReached,
                                         ShutDownApplication, ShutDownApplication,
                                         ApplicationConstants.ButtonWarningColor);
                        return;
                    }
                }

                ShowNotification(ex.Message, ReInitialize, ReInitialize,
                                 ApplicationConstants.ButtonWarningColor);
            }
            finally
            {
                var endTime = DateTime.Now;
                if (IsSwitchUserStarted)
                {
                    OperationsCompletedInSwitchUser++;
                }
            }
        }