public async Task <Result> DeleteDevice(int deviceAuthorizationId) { try { var device = await _db.DeviceAuthorizations .Include(x => x.Logins) .SingleOrDefaultAsync(x => x.Id == deviceAuthorizationId); if (device != null) { _db.RemoveRange(device.Logins); _db.Remove(device); await _db.SaveChangesAsync(); } return(Result.Success()); } catch (Exception e) { _logger.LogError($"Failed to delete device {deviceAuthorizationId}", e); return(Result.Failure("Failed to delete device")); } }