Esempio n. 1
0
        public async Task <IActionResult> Delete([FromBody] FlashObservationViewModel energyObservation)
        {
            _logger.LogInformation("Try to remove observation from database.");

            if (!ModelState.IsValid)
            {
                _logger.LogError($"Unable to remove observation with ID {energyObservation.Id} due to model state");

                return(BadRequest(ModelState));
            }

            try
            {
                await _service.DeleteObservationAsync(energyObservation);

                _logger.LogError($"Observation with id {energyObservation.Id} has been created successfully");

                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError($"Unable to remove observation with id {energyObservation.Id} due to: {ex.StackTrace}");

                return(BadRequest($"Cannot remove Flash Observation with id: {energyObservation.Id}"));
            }
        }
        public async Task <IActionResult> DeleteObservationAsync([FromBody] EnergyObservationModel flashObservation)
        {
            await _energyObservationService.DeleteObservationAsync(flashObservation);

            return(NoContent()); // ask: or return Ok();
        }