Esempio n. 1
0
        public async Task <IActionResult> Index()
        {
            // Get data for 7 days prior
            var recentReadings = await dbService.GetLatestReadings();

            var locationChartList = new List <LocationChartData>();
            var locationGroups    = recentReadings.GroupBy(i => i.Location).ToList();

            locationGroups.ForEach(group =>
            {
                var location = group.Select(i => i).FirstOrDefault()?.Location;

                var chartList = new List <ChartData>
                {
                    GetChartData(group.ToList(), ReadingType.NO2, location),
                    GetChartData(group.ToList(), ReadingType.Fine, location),
                    GetChartData(group.ToList(), ReadingType.Coarse, location)
                };

                locationChartList.Add(new LocationChartData()
                {
                    Location = location, Charts = chartList
                });
            });

            return(View(locationChartList));
        }