public async Task <IActionResult> Index() { var location = HttpContext.Session.GetString("LocationId"); EntityDTO dto = new EntityDTO { Id = Guid.Parse(location) }; List <ReadAnalyticDTO> analytics = await _analyticService.GetAllBeaconsWithHours(dto); IEnumerable <AnalyticViewModel> vm = analytics .GroupBy(row => new { Beacon = row.BeaconName, row.CreatedTime.Hour }).OrderByDescending(x => x.Key.Hour) .Select(grp => new AnalyticViewModel { Name = grp.Key.Beacon, Hour = grp.Key.Hour, Count = grp.Count() }); return(View(vm)); }