Exemplo n.º 1
0
        public decimal GetTotalExpenceAmount(int year)
        {
            decimal sum = 0;

            foreach (var ex in Expences.Where(x => x.Date.Year == year))
            {
                sum += ex.Amount;
            }

            return(sum);
        }
Exemplo n.º 2
0
        public decimal GetBalanceForDate(DateTime date)
        {
            var lastBalanceBeforeDate = Balances.Where(x => x.Date <= date).OrderByDescending(x => x.Date).FirstOrDefault();

            if (lastBalanceBeforeDate != null)
            {
                var sumExpences = Expences.Where(x => x.Date > lastBalanceBeforeDate.Date && x.Date <= date).Sum(x => x.Amount);
                var sumIncome   = Income.Where(x => x.Date > lastBalanceBeforeDate.Date && x.Date <= date).Sum(x => x.Amount);
                var sum         = sumIncome - sumExpences;
                return(lastBalanceBeforeDate.Amount + sum);
            }
            else
            {
                var sumExpences = Expences.Where(x => x.Date <= date).Sum(x => x.Amount);
                var sumIncome   = Income.Where(x => x.Date <= date).Sum(x => x.Amount);
                return(sumIncome - sumExpences);
            }
        }