Esempio n. 1
0
        internal bool SubmitMonthlyPayments()
        {
            var monthlyPayments = MonthlyPayments.Where(t => t.IsSelected);

            if (monthlyPayments.Count() > 0)
            {
                _quoteBuilder.SetMonthlyPayments(monthlyPayments.ToList());
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        internal async Task <RateOptionsSubmissionResult> SubmitRateOptions()
        {
            var equipmentAmount = EquipmentAmount.AsDouble();

            if (equipmentAmount > MaxEquipmentAmount || equipmentAmount < MinEquipmentAmount)
            {
                return(RateOptionsSubmissionResult.InvalidEquipmentAmount);
            }
            var pointAmount = Points.AsInt();

            if (pointAmount > MaxPoints)
            {
                return(RateOptionsSubmissionResult.InvalidPointAmount);
            }

            //need to get max points value

            var terms            = Terms.Where(t => t.IsSelected);
            var rateCards        = RateCards.Where(r => r.IsSelected);
            var maintenanceTypes = MaintenanceTypes.Where(m => m.IsSelected);
            var purchaseOptions  = PurchaseOptions.Where(p => p.IsSelected);
            var advancePayments  = AdvancePayments.Where(a => a.IsSelected);

            _quoteBuilder.SetRateOptions(new RateOptions
            {
                CompanyName          = CompanyName,
                EquipmentAmount      = EquipmentAmount.AsDouble(),
                EquipmentDescription = EquipmentDescription,
                RateCards            = rateCards.ToList(),
                Terms            = terms.ToList(),
                MaintenanceTypes = maintenanceTypes.ToList(),
                PurchaseOptions  = purchaseOptions.ToList(),
                Points           = Points.AsInt(),
                PassThrough      = PassThrough.AsInt(),
                AdvancePayments  = advancePayments.ToList()
            });
            try
            {
                _hudProvider.DisplayProgress("Retrieving Payment Options");

                var response = await _monthlyPaymentService.GetMonthlyPayments(_quoteBuilder.GetQuote());

                if (response != null)
                {
                    if (response.ErrorStatusCode == 400)
                    {
                        return(RateOptionsSubmissionResult.UnableToRetrieveData);
                    }
                    else if (response.ErrorStatusCode == 401)
                    {
                        return(RateOptionsSubmissionResult.Unauthorized);
                    }
                    else if (response.MonthlyPayments == null || response.MonthlyPayments.Count() == 0)
                    {
                        return(RateOptionsSubmissionResult.Failure);
                    }
                    else
                    {
                        _quoteBuilder.SetMonthlyPayments(response.MonthlyPayments.ToList());
                        return(RateOptionsSubmissionResult.Success);
                    }
                }
                return(RateOptionsSubmissionResult.Failure);
            }
            catch (Exception ex)
            {
                return(RateOptionsSubmissionResult.Failure);                //tell view to pop alert
            }
            finally
            {
                _hudProvider.Dismiss();
            }
        }