public ByInvestmentTableViewSource (UIViewController tvc, BalanceInfo balanceData) { Data = BalanceUtil.TransformBalanceData (balanceData); maxSourceRow = Data.Max (vm => vm.SourceAmounts.Count); maxViewModel = Data.First (vm => vm.SourceAmounts.Count == maxSourceRow); sourceNames = maxViewModel.SourceAmounts.Select (s => s.Key).ToList(); }
public static List<BalanceByInvestmentViewModel> TransformBalanceData(BalanceInfo balanceInfo) { var completeList = new List<BalanceByInvestmentRecord>(); foreach (var source in balanceInfo.sources) { var result = source.Funds.Select(fund => new BalanceByInvestmentRecord { SourceName = source.sourceName, FundName = fund.fundSourceName, FundAmount = fund.balance } ).ToList(); completeList.AddRange(result); } var DataGroups = completeList.OrderBy(o => o.FundName).ThenBy(o => o.SourceName).ToList(); var ByInvestmentData = new List<BalanceByInvestmentViewModel>(); var viewModels = DataGroups .GroupBy (x => x.FundName) .Select (x => new BalanceByInvestmentViewModel (x.First ().FundName) ).ToList (); viewModels.ForEach (model => model.SourceAmounts = completeList.Where(x => x.FundName == model.FundName) .ToDictionary(source => source.SourceName, amount => amount.FundAmount) ); foreach(var model in viewModels) { ByInvestmentData.Add (model); } return ByInvestmentData; }
public async override void OnResume () { base.OnResume (); try { var repo = App.Container.Resolve<IRSContentRepository> (); balances = await repo.GetBalance(); var dashboardInfo = await repo.GetDashboard(); bySourceAdapter = new BalanceSourceAdapter (Activity, balances.sources); byInvestmentAdapter = new BalanceByInvestmentAdapter (Activity, balances); text_title = (TextView) View.FindViewById (Resource.Id.txt_filter_header); totalBalance = balances.sources.Sum (x => x.totalBalance); vestedBalance = balances.sources.Sum(x => x.vestedBalance); txtBalDate.Text = String.Format ("Balances as of {0}", Convert.ToDateTime (dashboardInfo.totalBalanceValDate).ToString ("MM/dd/yy")); View footer = (( LayoutInflater )Activity.GetSystemService(Context.LayoutInflaterService )).Inflate(Resource.Layout.BalanceListFooter,null,false); footer.FindViewById<TextView> (Resource.Id.txt_total_bal_amt).Text = String.Format("{0:C}",balances.sources.Sum (x => x.totalBalance)); if(firstFootnote == null) { firstFootnote = footer.FindViewById<TextView> (Resource.Id.txt_first_footnote); } if(secondFootnote == null) { secondFootnote = footer.FindViewById<TextView> (Resource.Id.txt_second_footnote); } if(balanceList.FooterViewsCount <1) { balanceList.AddFooterView (footer); } spinner_bal_filter.ItemSelected += ItemSelectedClick; switch(spinner_bal_filter.SelectedItemPosition) { case 0: balanceList.Adapter = bySourceAdapter; text_title.Text = "Source"; if(vestedBalance > totalBalance) { firstFootnote.Visibility = ViewStates.Visible; secondFootnote.Visibility = ViewStates.Visible; } if(balanceList.FooterViewsCount <1) { balanceList.AddFooterView (footer); } break; case 1: balanceList.Adapter = byInvestmentAdapter; text_title.Text = "Investment"; firstFootnote.Visibility = ViewStates.Gone; secondFootnote.Visibility = ViewStates.Gone; break; } balanceList.ItemClick += DislcaimerClick; } catch (NoAccountsAvailableException naae) { Insights.Report (naae, new Dictionary <string, string> { {"Source", "Balance Resume"} }, ReportSeverity.Error); } catch (CurrentAccountNotSetException naae) { Insights.Report (naae, new Dictionary <string, string> { {"Source", "Balance Resume"} }, ReportSeverity.Error); } catch (TokenNotAvailableException tnae) { Insights.Report (tnae, new Dictionary <string, string> { {"Source", "Balance Resume"} }, ReportSeverity.Error); } catch (Exception e) { Insights.Report (e, new Dictionary <string, string> { {"Source", "Balance Resume"} }, ReportSeverity.Error); } }
public async void updateData() { var balanceRequest = new OAuthContentRequest<BalanceInfo> (AppCache.Instance.Ticket, DataAccessConfig.CONTENT_ENDPOINT); balances = await balanceRequest.postJsonForContent(DataAccessConfig.BALANCE_PATH, RequestObjectFactory.GetRequestObject(AppCache.Instance.GetCacheItem<AccountInfo>(AppCache.AppCacheKey.CURRENTACCOUNT))); bySourceAdapter.NotifyDataSetChanged (); byInvestmentAdapter.NotifyDataSetChanged (); }