Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            IEnumerable <Expense> _expenses = await _expenseDatabase.Expenses.ToListAsync();

            StatisticsIndexViewModel vm = new StatisticsIndexViewModel()
            {
                Expenses        = _expenses,
                HighestExpense  = _expenses.OrderByDescending(x => x.Amount).First(),
                LowestExpense   = _expenses.OrderBy(x => x.Amount).First(),
                MonthlyExpenses = _expenses.GroupBy(x => new { x.Date.Date.Month, x.Date.Year }).Select(g => new GroupedExpenses {
                    Date = new DateTime(g.Key.Year, g.Key.Month, 01), Amount = g.Sum(m => m.Amount)
                }).OrderBy(x => x.Date),
                HighestDayExpense = _expenses.GroupBy(x => x.Date.Date).Select(x => new GroupedExpenses {
                    Date = x.Key, Amount = x.Sum(m => m.Amount)
                }).OrderByDescending(x => x.Amount).First(),
                MostExpensive = _expenses.GroupBy(x => x.Category).Select(g => new GroupedExpenses {
                    Category = g.Key, Amount = g.Sum(m => (decimal)m.Amount)
                }).OrderByDescending(x => x.Amount).First(),
                LeastExpensive = _expenses.GroupBy(x => x.Category).Select(g => new GroupedExpenses {
                    Category = g.Key, Amount = g.Sum(m => (decimal)m.Amount)
                }).OrderBy(x => x.Amount).First()
            };

            return(View(vm));
        }
Exemplo n.º 2
0
        //街道统计
        public ActionResult Index()
        {
            StatisticsIndexViewModel viewModel = new StatisticsIndexViewModel();
            string ssjd = Request["ssjd"];

            RoadFlow.Platform.DictionaryBLL DictionaryBLL = new RoadFlow.Platform.DictionaryBLL();
            viewModel.ParaSSJD = new SelectList(DictionaryBLL.GetListByCode("SSJD").ToList <RoadFlow.Data.Model.DictionaryModel>(), "ID", "Title", ssjd);;
            viewModel.List     = BuildingsStreetStatisticsBLL.GetBySSJD(ssjd);
            return(View(viewModel));
        }
        public IActionResult Index()
        {
            StatisticsIndexViewModel sivm = new StatisticsIndexViewModel
            {
                Highest         = _expensesDB.GetHighest(),
                Lowest          = _expensesDB.GetLowest(),
                MostSpendDay    = _expensesDB.GetMostSpendDay(),
                MostSpendAmount = _expensesDB.GetMostSpendAmount()
            };

            return(View(sivm));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Index()
        {
            var expenses = await _expenseDbContext.Expenses.ToListAsync();

            StatisticsExpenseModel highestShow = null;
            StatisticsExpenseModel lowestShow  = null;

            Expense highest = expenses.OrderByDescending(x => x.Amount).FirstOrDefault();

            Expense lowest = expenses.OrderBy(x => x.Amount).FirstOrDefault();

            if (highest != null)
            {
                highestShow = new StatisticsExpenseModel
                {
                    Amount      = highest.Amount,
                    Description = highest.Description,
                    Date        = highest.Date
                };
            }

            if (lowest != null)
            {
                lowestShow = new StatisticsExpenseModel
                {
                    Amount      = lowest.Amount,
                    Description = lowest.Description,
                    Date        = lowest.Date
                };
            }

            var statistics = new StatisticsIndexViewModel();

            if (expenses.Count > 0)
            {
                var(highestCategoryId, highestCategoryExpense) = HighestCategoryExpense(expenses);
                var highestCategoryItem = await _expenseDbContext.Categories.FindAsync(highestCategoryId);

                var(lowestCategoryId, lowestCategoryExpense) = LowestCategoryExpense(expenses);
                var lowestCategoryItem = await _expenseDbContext.Categories.FindAsync(lowestCategoryId);

                statistics.Highest         = highestShow;
                statistics.Lowest          = lowestShow;
                statistics.HighestDay      = GetHighestDay(expenses);
                statistics.Monthly         = MonthlyExpenses(expenses);
                statistics.HighestCategory = (highestCategoryItem.Description, highestCategoryExpense);
                statistics.LowestCategory  = (lowestCategoryItem.Description, lowestCategoryExpense);
            }

            return(View(statistics));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Index()
        {
            IEnumerable <Media> _medias = await _mediaDatabase.medias.ToListAsync();

            StatisticsIndexViewModel vm = new StatisticsIndexViewModel()
            {
                medias        = _medias,
                Highestrating = _medias.OrderByDescending(x => x.Rating).First(),
                Lowestmedia   = _medias.OrderBy(x => x.Rating).First(),
                MostPopular   = _medias.GroupBy(x => x.Category).Select(g => new Groupedmedias {
                    Category = g.Key, Rating = g.Sum(m => (int)m.Rating)
                }).OrderByDescending(x => x.Rating).First(),
                LeastPopular = _medias.GroupBy(x => x.Category).Select(g => new Groupedmedias {
                    Category = g.Key, Rating = g.Sum(m => (int)m.Rating)
                }).OrderBy(x => x.Rating).First()
            };

            return(View(vm));
        }
Exemplo n.º 6
0
        public IActionResult Index()
        {
            StatisticsIndexViewModel vm = new StatisticsIndexViewModel()
            {
                Expenses        = _expenses,
                HighestExpense  = _expenses.OrderByDescending(x => x.Amount).First(),
                LowestExpense   = _expenses.OrderBy(x => x.Amount).First(),
                MonthlyExpenses = _expenses.GroupBy(x => new { x.Date.Date.Month, x.Date.Year }).Select(g => new GroupedExpenses {
                    Date = new DateTime(g.Key.Year, g.Key.Month, 01), Amount = g.Sum(m => m.Amount)
                }).OrderBy(x => x.Date),
                HighestDayExpense = _expenses.GroupBy(x => x.Date.Date).Select(x => new GroupedExpenses {
                    Date = x.Key, Amount = x.Sum(m => m.Amount)
                }).OrderByDescending(x => x.Amount).First(),
                MostExpensive = _expenses.GroupBy(x => x.Category).Select(g => new GroupedExpenses {
                    Category = g.Key.Name, Amount = g.Sum(m => m.Amount)
                }).OrderByDescending(x => x.Amount).First(),
                LeastExpensive = _expenses.GroupBy(x => x.Category).Select(g => new GroupedExpenses {
                    Category = g.Key.Name, Amount = g.Sum(m => m.Amount)
                }).OrderBy(x => x.Amount).First()
            };

            return(View(vm));
        }