public async Task <IActionResult> GetReportsData(bool update = false) { try { _logger?.LogDebug("GetReportsData()..."); if (!_wallbox.IsLocked) { return(StatusCode(StatusCodes.Status406NotAcceptable, "Locked: update not yet finished.")); } if (update) { await _wallbox.ReadReportsAsync(); if (!_wallbox.Data.IsGood) { return(StatusCode(StatusCodes.Status502BadGateway, _wallbox.Data.Status)); } } return(Ok(_wallbox.Reports)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public async Task TestReadData() { var status = await _wallbox.ReadReport1Async(); Assert.True(status.IsGood); Assert.True(_wallbox.Report1.Status.IsGood); status = await _wallbox.ReadReport2Async(); Assert.True(status.IsGood); Assert.True(_wallbox.Report2.Status.IsGood); status = await _wallbox.ReadReport3Async(); Assert.True(status.IsGood); Assert.True(_wallbox.Report3.Status.IsGood); status = await _wallbox.ReadReport100Async(); Assert.True(status.IsGood); Assert.True(_wallbox.Report100.Status.IsGood); status = await _wallbox.ReadReportsAsync(); Assert.True(status.IsGood); foreach (var report in _wallbox.Reports) { Assert.True(report.Status.IsGood); } }