public async Task <IActionResult> ShutdownVm(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 shutdownVmResponse = new ServicesResponse(); switch (adapter.Provider.Name.ToLower()) { case "ovirt": shutdownVmResponse = await VmService.ShutdownVm(adapter, vM.Id); if (shutdownVmResponse.isSuccess) { } else { return(BadRequest(shutdownVmResponse.errorMessage)); } break; } return(Ok(shutdownVmResponse)); }