/*public void OfferTrip_Refreshing(object sender, EventArgs e)
         * {
         *  GetTripsOffered();
         *  OfferTrip.EndRefresh();
         * }*/

        public async void OfferTrip_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            try
            {
                if (e.SelectedItem == null)
                {
                    return;
                }

                using (TripRepository tripRepository = new TripRepository())
                {
                    var selectedTrip = e.SelectedItem as Trip;
                    OfferTrip.SelectedItem = null;

                    var response = await tripRepository.TripIsEnable(selectedTrip.TripId);

                    if (!response)
                    {
                        await DisplayAlert("Alert", "The trip is no longer available", "Ok");

                        GetTripsOffered();
                        return;
                    }

                    int seatsAvailableOnATrip = await tripRepository.GetSeatsAvailableOnATrip(selectedTrip.TripId);

                    if (seatsAvailableOnATrip == 0)
                    {
                        await DisplayAlert("Alert", "Trip with no available seats", "Ok");

                        GetTripsOffered();
                        return;
                    }

                    var confirmTrip = await ConfirmPostTrip(Navigation, selectedTrip);

                    if (confirmTrip)
                    {
                        var reusableLoading = Loading.Instance.Create <LoadingDialog>();

                        reusableLoading.Show();
                        await tripRepository.AddPassengerOnATrip(_user, selectedTrip.TripId);

                        await Navigation.PushAsync(new TripAcceptedPage(selectedTrip, _user));

                        reusableLoading.Hide();
                    }
                }
            }
            catch (Exception exc)
            {
                await DisplayAlert("Error", "An unexpected error has occurred" + exc.Message, "Ok");
            }
        }