public async Task <IActionResult> Post([FromBody] BaseComponentViewModel bootViewModel) { try { var id = Guid.Parse(bootViewModel.ModuleId); var bootMessage = new BootMessage { ModuleId = id, State = bootViewModel.State }; await BootMessageRepository.CreateBootMessage(bootMessage); await ModuleRepository.UpdateModuleHeartbeat (new Module(id, bootViewModel.State)); var moduleResponse = await BootMessageRepository .PostBootToBackendApi(bootMessage); return(Ok(moduleResponse)); } catch (Exception ex) { Logger.LogError(ex.Message); return(BadRequest(new ErrorResponse(ex))); } }
public async Task SaveBootMessage(BootMessage bootMessage) { using (DataContext = new SimplySecureDataContext()) { DataContext.BootMessages.Add(bootMessage); await DataContext.SaveChangesAsync(); } }