コード例 #1
0
        public IActionResult Index()
        {
            var viewModel = new BaseStatisticsViewModel
            {
                MostPopularService  = _statisticsManager.GetMostPopularService(),
                LeastPopularService = _statisticsManager.GetLeastPopularService(),
                TotalSum            = _statisticsManager.GetTotalPrice(),
                //Services = _context.Services.Include(s=>s.GiftServices).ThenInclude(gs=>gs.Gift).ThenInclude(g=>g.User).Select(ser=>
                //    new ServiceBaseViewModel
                //    {
                //        ServiceName = ser.Name,
                //        AvarageAgeOfCustomer = Convert.ToInt32(ser.GiftServices.Average(gs => (double)(DateTime.Now.Year - gs.Gift.User.YearOfBirth.GetValueOrDefault(1900)))),
                //        MinAgeOfUser = ser.GiftServices.Min(gs => DateTime.Now.Year - gs.Gift.User.YearOfBirth.GetValueOrDefault(1900)),
                //        MaxAgeOfUser = ser.GiftServices.Max(gs => DateTime.Now.Year - gs.Gift.User.YearOfBirth.GetValueOrDefault(1900))
                //    }).ToList()
            };

            return(View(viewModel));
        }