public Analytic GetAnalytic()
        {
            Analytic analytic = new Analytic();
            Dictionary <string, List <Capital> > allCapitals = CapitalRepository.GetRepository().GetAll();

            foreach (List <Capital> capitals in allCapitals.Values)
            {
                foreach (Capital capital in capitals)
                {
                    if (capital is Income)
                    {
                        analytic.totalIncome += capital.amount;
                    }
                    else
                    {
                        analytic.totalConsumption += capital.amount;
                    }
                }
            }
            foreach (string category in allCapitals.Keys)
            {
                foreach (Capital capital in allCapitals[category])
                {
                    if (capital is Income)
                    {
                        analytic.sumIncomeByCategory(category, capital.amount);
                    }
                    else
                    {
                        analytic.sumConsumptionByCategory(category, capital.amount);
                    }
                }
            }
            return(analytic);
        }
 public static CapitalRepository GetRepository()
 {
     if (repository == null)
     {
         repository = new CapitalRepository();
     }
     return(repository);
 }
 public void AcceptConsumtion(double amount, DateTime date, string category)
 {
     consumption = new Consumption(amount, date, category);
     CapitalRepository.GetRepository().Save(consumption);
 }
 public void AcceptIncome(double amount, DateTime date, string category)
 {
     income = new Income(amount, date, category);
     CapitalRepository.GetRepository().Save(income);
 }