Exemplo n.º 1
0
        public void InvolveEveryone()
        {
            Recalculate();
            var alreadyPresentDebtors = Debtors.Where(t => t.UserId != null).Select(t => t.UserId).ToArray();
            var missingDebtors        = AllUsers.Where(t => alreadyPresentDebtors.All(d => d != t.Id)).ToArray();
            var missingTransactions   = missingDebtors.Select(t => new TransactionData()
            {
                UserId = t.Id, Name = t.Name, Amount = AmountDifference / missingDebtors.Count()
            });

            Debtors.AddRange(missingTransactions);

            DebtorsChanged();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Recalculates the remaining amount.
 /// </summary>
 public void Recalculate()
 {
     AmountDifference = (Payers.Where(p => p.Amount != null).Sum(p => p.Amount) ?? 0) - (Debtors.Where(p => p.Amount != null).Sum(p => p.Amount) ?? 0);
 }