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(); } }
public async Task <bool> LoadRateOptions() { var quote = _quoteBuilder.GetQuote(); if (quote.RateCards != null) { return(true); } PointsVisible = true; PassThroughVisible = true; //call service to get rate card options for dealer try { _hudProvider.DisplayProgress("Getting Rate Cards"); //Pass through Amount - maintenance Amount //Maintenance Type - pick list var response = await _rateCardService.GetRateCards(); if (response != null) { if (response.ErrorStatusCode.IsErrorCode()) { _hudProvider.Dismiss(); return(false); } else { RateCards = response.RateCardsLocal; if (RateCards.Count() > 0) { //getting terms var termList = new List <TermItem>(); foreach (int item in RateCards.SelectMany(x => x.Terms.Select(t => t.Term)).Distinct()) { termList.Add(new TermItem { IsSelected = false, Term = item, TermDisplay = item.ToString() + " months" }); } Terms = termList; Terms.OrderBy(m => m.Term); //getting maintenance types MaintenanceTypes = RateCards.SelectMany(x => x.MaintenanceTypes).GroupBy(p => p.MaintenanceTypeDescription).Select(g => g.First()).ToList(); //getting purchase options PurchaseOptions = RateCards.SelectMany(x => x.PurchaseOptions).GroupBy(p => p.PurchaseOptionDesc).Select(g => g.First()).ToList(); //getting advance payments AdvancePayments = RateCards.SelectMany(x => x.AdvancePayments).GroupBy(p => p.AdvancePaymentDescription).Select(g => g.First()).ToList(); MaxPoints = RateCards.Max(rc => rc.AvailablePoints); MaxEquipmentAmount = RateCards.Max(rc => rc.MaximumAmount); MinEquipmentAmount = RateCards.Min(rc => rc.MinimumAmount); } } } } catch (Exception ex) { } finally { _hudProvider.Dismiss(); } return(true); }