private async void processData() { string username = this.UsernameTextBox.Text; string password = this.passwordTextBox.Text; AppRepo repo = new AppRepo(); if (NetworkConnectivity.DnsTest()) { isBusy(true); var data = await repo.loginUser(new LoginDataModel { email = username, password = password }); if (data != null && data.status) { DatabaseOperations.saveToken(data); this.Hide(); var mainform = new MainForm(); mainform.Closed += (s, args) => this.Close(); mainform.Show(); } else { isBusy(false); errorProvider1.SetError(this.UsernameTextBox, "Login was not successful. Try again later"); return; } } else { MessageBox.Show(Constants.INTERNET_CONNECTION_ERR_MSG, Constants.INTERNET_CONNECTION_ERROR); return; } }
private async void loadDataFromServer() { if (NetworkConnectivity.DnsTest()) { isBusy(true); FoodItemsDataModel data = await getDatafromServerAsync(); isBusy(false); if (data != null && data.status && data.results != null) { populateDataFromServer(data.results); DatabaseOperations.addData(data.results); } } else { MessageBox.Show(Constants.INTERNET_CONNECTION_ERR_MSG, Constants.INTERNET_CONNECTION_ERROR); } }