private async void OnSaveParameters(object sender, System.EventArgs e) { _model.SaveParameters(); using (UserDialogs.Instance.Loading("Testing database connection...")) { if (_wifiConnectionChecker.CheckConnection() != WifiConnectionResponse.WIFI_DATA_INTERNET) { await DisplayAlert("Error", "Not connected to wifi network. Connect before retrying.", "OK"); return; } bool connected = await Task.Run(() => _model.TestConnection()); if (connected) { await Navigation.PushAsync(App.Container.Resolve <ParametersPage>()); } else { await DisplayAlert("Error", "Bad connection string.", "OK"); } } }
protected RestaurantContext CreateContext() { try { var response = _wifiConnectionChecker.CheckConnection(); if (response == WifiConnectionResponse.WIFI_DATA_INTERNET) { var restaurantDatabaseContext = new RestaurantContext(); restaurantDatabaseContext.Database.EnsureCreated(); restaurantDatabaseContext.Database.Migrate(); return(restaurantDatabaseContext); } else { string msg = _wifiConnectionResponseParser.GenerateResponse(response); throw new WifiConnectionException(msg); } } catch (SqlException) { throw new ConnectionStringException(); } }