public async void createMission(Object sender, EventArgs e) { Mission createdMission = new Mission() { description = missionDescriptionText.Text }; if (!string.IsNullOrEmpty(priorityText.Text)) { createdMission.priority = int.Parse(priorityText.Text); } if (!string.IsNullOrEmpty(longitudeText.Text) && !string.IsNullOrEmpty(latitudeText.Text)) { createdMission.location = new GeoPoint() { Latitude = int.Parse(latitudeText.Text), Longitude = int.Parse(longitudeText.Text) }; } try { createdMission = await Missions.Create(createdMission); creationStatus.SetTextColor(Android.Graphics.Color.Green); creationStatus.Text = "Mission created successfully."; missionDescriptionText.Text = ""; priorityText.Text = ""; latitudeText.Text = ""; longitudeText.Text = ""; updateMissions(null, null); } catch (RestException exception) { creationStatus.SetTextColor(Android.Graphics.Color.Red); creationStatus.Text = "Creation failed."; if (exception.StatusCode == 401) { Toast.MakeText(this, "Creation failed: You are not authorized to create, please log in.", ToastLength.Short).Show(); } else if (exception.StatusCode == 422) { Toast.MakeText(this, "Creation failed: Please make sure that you've filled all the required mission details.", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Creation failed" + exception.StatusCode.ToString(), ToastLength.Short).Show(); } } }