public App() { InitializeComponent(); //Initialise control vars ControlVars c = new ControlVars(); c.setAlert(new Alert("NONE", "NONE", "NONE", DateTime.Now, false)); //Initialise server connection serverConnection conn = new serverConnection(); /* * Task<string> task = serverConnection.testRequest(); * task.Wait(); * string x = task.Result; * Console.WriteLine(x); */ //MainPage = new MainPage(); MainPage = new NavigationPage(new MainPage()); }
async void UpdateAlertButtonClicked() { //Check if things aren't set string errorStr = ""; if (alertTypePicker.SelectedItem.ToString().Equals("")) { errorStr += "Alert type not set\n"; } if (endTime.Time <= TimeSpan.Parse(DateTime.Now.ToString())) { errorStr += "End time is before start time\n"; } //If things aren't set, show error //If they are then create an alert if (!errorStr.Equals("")) { errorStr = "Coult not create alert\n" + errorStr; await DisplayAlert("Error", errorStr, "OK"); } else //Create alert here { try { bool f = true; if (c.getAlert().getActive() == true) { f = await DisplayAlert("Error", "You already have an active alert. Do you want to cancel it?", "Yes", "No"); } if (f) { c.setAlert(new Alert(getLat(), getLon(), alertTypePicker.SelectedItem.ToString(), DateTime.Parse(endTime.Time.ToString()), true)); //Then update the website } } catch (Exception e) { await DisplayAlert("Error", "Could not create alert\n" + e.Message, "OK"); } } }