예제 #1
0
        public async Task <IActionResult> Get([FromRoute] int panelId)
        {
            var panel = await _panelRepository.FindAsync(x =>
                                                         x.Id.Equals(panelId));

            if (panel == null)
            {
                return(NotFound());
            }

            var analytics = await _analyticsRepository
                            .FindAllAsync(x => x.PanelId.Equals(panelId));

            var result = new OneHourElectricityListModel
            {
                OneHourElectricitys = analytics.Select(c => new OneHourElectricityModel
                {
                    Id       = c.Id,
                    KiloWatt = c.KiloWatt,
                    DateTime = c.DateTime
                })
            };

            return(Ok(result));
        }