public async Task <IActionResult> PutZetronMstIncidents([FromRoute] int id, [FromBody] ZetronMstIncidents zetronMstIncidents) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != zetronMstIncidents.IncidentId) { return(BadRequest()); } try { var recordtoUpdate = _context.ZetronMstIncidents.Single(i => i.IncidentId == id); if (recordtoUpdate.Status != zetronMstIncidents.Status) { recordtoUpdate.Status = zetronMstIncidents.Status; Task incidentUpdate = _context.SaveChangesAsync(); switch (zetronMstIncidents.Status) { case (int)IncidentStatus.Processing: //trigger job incidentUpdate.Wait(); _mediaContext.TriggerJob(id); break; case (int)IncidentStatus.Stopped: _mediaContext.StopAzureProcess(id, IncidentStatus.Stopped); break; case (int)IncidentStatus.Deactivated: _mediaContext.StopAzureProcess(id, IncidentStatus.Deactivated); break; default: break; } } } catch (DbUpdateConcurrencyException) { if (!ZetronMstIncidentsExists(id)) { return(NotFound()); } else { throw; } } return(CreatedAtAction("GetZetronMstIncidents", new { id = zetronMstIncidents.IncidentId }, zetronMstIncidents)); }