Exemplo n.º 1
0
        public Dictionary <string, decimal> CalculateMonthlyExpense()
        {
            ExpensesDataAcessLayer       objexpense     = new ExpensesDataAcessLayer();
            List <ExpenseReport>         lstEmployee    = new List <ExpenseReport>();
            Dictionary <string, decimal> dictMonthlySum = new Dictionary <string, decimal>();
            decimal foodSum = db.ExpenseReport.Where
                                  (cat => cat.Category == "На Еду" && (cat.ExpenseDate > DateTime.Now.AddMonths(-1)))
                              .Select(cat => cat.Amount)
                              .Sum();
            decimal shoppingSum = db.ExpenseReport.Where
                                      (cat => cat.Category == "Переодические расходы" && (cat.ExpenseDate > DateTime.Now.AddMonths(-1)))
                                  .Select(cat => cat.Amount)
                                  .Sum();
            decimal travelSum = db.ExpenseReport.Where
                                    (cat => cat.Category == "Постоянные расходы" && (cat.ExpenseDate > DateTime.Now.AddMonths(-1)))
                                .Select(cat => cat.Amount)
                                .Sum();
            decimal healthSum = db.ExpenseReport.Where
                                    (cat => cat.Category == "Прочие расходы" && (cat.ExpenseDate > DateTime.Now.AddMonths(-1)))
                                .Select(cat => cat.Amount)
                                .Sum();

            dictMonthlySum.Add("На Еду", foodSum);
            dictMonthlySum.Add("Переодические расходы", shoppingSum);
            dictMonthlySum.Add("Постоянные расходы", travelSum);
            dictMonthlySum.Add("Прочие расходы", healthSum);
            return(dictMonthlySum);
        }