private async Task <List <ClashClanMember> > loadClashClanMembers() { try { clanMembers = await ClashRoyaleHttpHelper.GetClanMembersAsync(); foreach (ClashClanMember member in clanMembers) { member.DonationsRatio = (float)member.Donations / member.DonationsReceived; } } catch (Exception ex) { } return(clanMembers); }
private async void fillMembersPanel() { clanMembers = await loadClashClanMembers(); if (clanMembers == null) { MessageBox.Show("Error al cargar los miembros", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { warLogs = await ClashRoyaleHttpHelper.GetWarLog(); Thickness margins; if (clanMembers == null)//TODO:add error message { return; } List <ClashClanMember> clanMembersOrdered = clanMembers.OrderByDescending(o => o.DonationsRatio).ToList(); foreach (ClashClanMember member in clanMembersOrdered) { Button newButton = new Button(); newButton.Content = member.Name; margins = newButton.Margin; margins.Top = 2; margins.Bottom = 2; newButton.Margin = margins; newButton.Tag = member.Tag; newButton.Click += btnGetUserStats; panelMembers.Children.Add(newButton); } } }