Пример #1
0
        public ActionResult Subdetails()
        {
            IList <Statistics> stat = new List <Statistics>();

            stat = _statisticsesService.GetAll();

            var subdetails = new SubDetailsViewModel
            {
                Today     = stat.Count(d => d.DateStamp.Day == DateTime.Now.Day),
                LastDay   = stat.Count(d => d.DateStamp.Day == DateTime.Now.Day - 1),
                ThisMonth = stat.Count(m => m.DateStamp.Month == DateTime.Now.Month),
                ThisYear  = stat.Count(y => y.DateStamp.Year == DateTime.Now.Year),
                PeakDate  = stat.GroupBy(x => x.DateStamp.ToShortDateString()).OrderByDescending(grouping => grouping.Count()).First().Key.AsDateTime(),
                LowDate   = stat.GroupBy(x => x.DateStamp.ToShortDateString()).OrderByDescending(grouping => grouping.Count()).Last().Key.AsDateTime(),
            };

            //MostVisitedDate();

            return(PartialView(subdetails));
        }
        public ActionResult Subdetails()
        {
            IList <Statistics> stat = new List <Statistics>();

            using (var db = new AppDbContext())
            {
                stat = db.Statisticses.AsNoTracking().ToList();
            }

            var subdetails = new SubDetailsViewModel
            {
                Today     = stat.Count(d => d.DateStamp.Day == DateTime.Now.Day),
                LastDay   = stat.Count(d => d.DateStamp.Day == DateTime.Now.Day - 1),
                ThisMonth = stat.Count(m => m.DateStamp.Month == DateTime.Now.Month),
                ThisYear  = stat.Count(y => y.DateStamp.Year == DateTime.Now.Year),
                PeakDate  = stat.GroupBy(x => x.DateStamp.ToShortDateString()).OrderByDescending(grouping => grouping.Count()).First().Key.AsDateTime(),
                LowDate   = stat.GroupBy(x => x.DateStamp.ToShortDateString()).OrderByDescending(grouping => grouping.Count()).Last().Key.AsDateTime(),
            };

            //MostVisitedDate();

            return(PartialView("_SubDetailsPartial", subdetails));
        }