public async Task <IActionResult> Post([FromBody] BaseComponentViewModel bootViewModel) { try { var module = await _moduleRepository.FindModule (Guid.Parse(bootViewModel.ModuleId)); if (module == null) { return(BadRequest(new Exception(ErrorMessageResponses.InvalidModuleId))); } await _bootRepository .SaveBootMessage (new BootMessage(module.Id, bootViewModel.State)); var moduleResponse = await LocationTriggeringService .DetermineIfTriggering(_locationRepository, _locationActionEventsRepository, _messagingService, module); module.State = bootViewModel.State; await _moduleRepository.UpdateModuleLastBoot(module); return(Ok(moduleResponse)); } catch (Exception ex) { Logger.LogError(ex.Message); return(BadRequest(new ErrorResponse(ex))); } }
public async Task <IActionResult> DeleteModule(Guid id) { try { var module = await _moduleRepository.FindModule(id); if (module == null) { return(BadRequest(new ErrorMessage(ErrorMessageResponses.UnableToFindModule))); } await _moduleRepository.DeleteModule(module); return(Ok(id)); } catch (Exception ex) { Logger.LogError(ex.Message); return(BadRequest(new ErrorResponse(ex))); } }