public async Task <bool> SyncFromServer(int method) { timeStart = DateTime.Now; totalRowInserted = 0; totalRowUpdated = 0; Debug.WriteLine("Sync Invoice From Server Started!"); if (!Settings.LastSyncInvoice.Equals("0")) { await SyncToServer(method); } int page = 0; bool NeedToSync = true; while (NeedToSync) { string url = ApiURI.URL_BASE(CurrentAccount) + ApiURI.URL_GET_INVOICE(CurrentUserName, Settings.CurrentPassword, Settings.LastSyncInvoice, page); Debug.WriteLine("url: " + url); var response = await restClient.GetStringAsync(url); Debug.WriteLine("Response Invoice: " + response); if (!string.IsNullOrWhiteSpace(response) && !response.Equals("[]")) { ProcessData(response); page++; } else { SetLastSyncInvoice(); NeedToSync = false; } } Debug.WriteLine("Sync Invoice Time: " + DateTime.Now.Subtract(timeStart).TotalSeconds); Debug.WriteLine("Total Invoice Inserted: " + totalRowInserted); Debug.WriteLine("Total Invoice Updated: " + totalRowUpdated); Debug.WriteLine("Sync Invoice From Server Ended!"); return(await Task.FromResult(true)); }