async Task ExecuteLoadUsersCommand() { if (IsBusy) { return; } IsBusy = true; try { UserDebts.Clear(); var userDebts = await App.Database.GetUserDebtsAsync(); foreach (var debt in userDebts) { UserDebts.Add(debt); } } catch (Exception e) { Debug.WriteLine(e); } finally { IsBusy = false; } }
public List <Debt> GetUserDebtsByGroupPerUrersAsync(GroupDTO group) { var userDebts = new UserDebts(); var users = group.Users.ToList(); foreach (var u in users) { var userPayments = group.Operations.Where(x => x.Owner.Id == u.Id) .Sum(x => x.Amount); if ((userPayments / users.Count) > 0) { var debtors = users.Where(x => x.Id != u.Id); foreach (var d in debtors) { userDebts.Add(u.Name, Math.Round((userPayments / users.Count), 2), d.Name); } } } return(ResolveDebts(userDebts)); }