Beispiel #1
0
        private async void CreateClick(Object sender, EventArgs e)
        {
            if (ValidateData())
            {
                iTrip.distance = distanceValue;
                iTrip.duration = durationValue;
                iTrip.cost     = Double.Parse(txtviewCost.Text.ToString().Substring(2, txtviewCost.Text.ToString().Length - 2),
                                              System.Globalization.CultureInfo.InvariantCulture);
                iTrip.distanceStr = txtviewDistance.Text.ToString();
                iTrip.durationStr = txtviewDuration.Text.ToString();
                iTrip.costStr     = txtviewCost.Text.ToString();
                // Assign user input and request POST to REST API
                iTrip.arriveTime = onTimeSet.ToString();
                iTrip.days       = tvDay.Text.ToString();

                if (switchFemaleOnly.Checked)
                {
                    iTrip.femaleOnly = "Yes";
                }
                else
                {
                    iTrip.femaleOnly = "No";
                }

                TripDriver    tripDriver;
                TripPassenger tripPassenger;

                progress.SetMessage("Creating trip...");
                RunOnUiThread(() =>
                {
                    progress.Show();
                });
                if (iMember.type.Equals("Driver"))
                {
                    tripDriver               = new TripDriver(iTrip);
                    tripDriver.DriverID      = iMember.MemberID;
                    tripDriver.availableSeat = int.Parse(spinnerSeat.SelectedItem.ToString());
                    var json = JsonConvert.SerializeObject(tripDriver);
                    await RESTClient.CreateTripDriverAsync(this, tripDriver);
                }
                else
                {
                    tripPassenger             = new TripPassenger(iTrip);
                    tripPassenger.PassengerID = iMember.MemberID;
                    var json = JsonConvert.SerializeObject(tripPassenger);
                    await RESTClient.CreateTripPassengerAsync(this, tripPassenger);
                }
                RunOnUiThread(() =>
                {
                    progress.Dismiss();
                });
                Intent intent = new Intent(this, typeof(MainActivity));
                intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask);
                StartActivity(intent);
                Finish();
            }
        }