public NotificationData(Person person, NotificationLevel notificationLevel, GpsLocation gpsLocation) { dictionaryJson = new Dictionary<string, string>(); dictionaryJson.Add("Name", person.Name); dictionaryJson.Add("Surname", person.Surname); dictionaryJson.Add("Notification", ((int)notificationLevel).ToString()); dictionaryJson.Add("Latitude", gpsLocation.Latitude.ToString().Replace(',', '.')); dictionaryJson.Add("Longitude", gpsLocation.Longitude.ToString().Replace(',', '.')); }
private async void SendNotification(object sender, EventArgs e) { EditText nameEditText = FindViewById<EditText>(Resource.Id.firstNameTextField); EditText surnameEditText = FindViewById<EditText>(Resource.Id.surNameTextField); person = new Person(nameEditText.Text, surnameEditText.Text); Button button = sender as Button; Console.WriteLine("Button {0} pressed", button.Text); DataUpload dataUploader = new DataUpload("http://pluton.kt.agh.edu.pl/~ppiatek/jpwp/api.php"); bool result = await dataUploader.SendJSON(new NotificationData(person, (NotificationLevel)Convert.ToInt32(button.Text), new GpsLocationAndroid(gpsLocation))); if (result) ShowAlertDialog("Sukces", "Zgłoszenie zostało wysłane na serwer"); else ShowAlertDialog("Brak dostępu do Internetu", "Znajdź dostęp do sieci i spróbuj ponownie"); }