public async Task <IActionResult> ChangeState(Vm vM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (vM?.Adapter == null) { return(BadRequest()); } Adapter adapter = await _context.Adapters.Where(x => x.IsOK) .Include(c => c.Credentials) .Include(p => p.Provider) .Where(a => a.Id == vM.Adapter.Id) .SingleOrDefaultAsync(); ServicesResponse changeStateVmResponse = new ServicesResponse(); switch (adapter.Provider.Name.ToLower()) { case "ovirt": string shutOrStart = vM.Status == "down" ? "start" : "shutdown"; changeStateVmResponse = await VmService.ChangeState(adapter, vM.Id, shutOrStart); if (changeStateVmResponse.isSuccess) { _logger.LogInformation($"CHANGE STATUS : {vM.Status}"); _logger.LogInformation($"CHANGE STATUS : {changeStateVmResponse.resultObject}"); } else { return(BadRequest(changeStateVmResponse.errorMessage)); } break; } return(Ok(changeStateVmResponse)); }