public async Task <IActionResult> DeleteConfirmed(int id) { var device = await db.Device.FindAsync(id); db.Device.Remove(device); await db.SaveChangesAsync(); // Edit device in cloud Task <bool> t1 = cloud.DeleteDevice(device); Task.WaitAll(t1); if (t1.Result) { //device deleted } return(RedirectToAction(nameof(Index))); }