Exemplo n.º 1
0
        private async void OnCancelReservation(object sender, EventArgs e)
        {
            bool answer = await DisplayAlert("Cancel Reservation", "Are you sure?", "Accept", "Cancel");

            if (answer)
            {
                var reservation = new Reservations {
                    ID_Route = route.ID, ID_User = currentUser.ID
                };
                IsBusy = true;
                await reservationsManager.DeleteReservationAsync(reservation);

                IsBusy = false;
                await DisplayAlert("Success", "Reservation Canceled", "Accept");

                await Navigation.PopAsync(true);
            }
        }
        public async Task DeleteReservationAsync(Reservations reservation)
        {
            try
            {
                List <Reservations> reservationsList = await GetReservationsWhere(res => res.ID_Route == reservation.ID_Route && res.ID_User == reservation.ID_User);

                foreach (var res in reservationsList)
                {
                    await reservationsTable.DeleteAsync(res);
                }
            }
            catch (MobileServiceInvalidOperationException msioe)
            {
                Debug.WriteLine(@"INVALID {0}", msioe.Message);
            }
            catch (Exception e)
            {
                Debug.WriteLine(@"ERROR {0}", e.Message);
            }
        }
Exemplo n.º 3
0
        private async void OnReserved(object sender, EventArgs e)
        {
            bool r = await DisplayAlert("Reservation", "Add reservation?", "Accept", "Cancel");

            if (r == true)
            {
                activityIndicator.IsRunning = true;

                var newReservation = new Reservations
                {
                    ID_Route = route.ID,
                    ID_User  = currentUser.ID
                };

                await reservationsManager.SaveReservationAsync(newReservation);

                activityIndicator.IsRunning = false;
                cancelButton.IsVisible      = true;
                reserveButton.IsVisible     = false;
            }
        }
Exemplo n.º 4
0
        private async void LoadReservation()
        {
            string id_user  = currentUser.ID;
            string id_route = route.ID;

            Reservations reservation = new Reservations
            {
                ID_User  = id_user,
                ID_Route = id_route
            };

            List <Reservations> reservationResult = await reservationsManager.GetReservationsWhere(reserv => reserv.ID_Route == reservation.ID_Route && reserv.ID_User == reservation.ID_User);

            if (reservationResult.Count != 0)
            {
                cancelButton.IsVisible  = true;
                reserveButton.IsVisible = false;
            }
            else
            {
                reserveButton.IsVisible = true;
            }
        }
Exemplo n.º 5
0
        private async void LoadData()
        {
            this.IsBusy = true;

            userRoute = await usersManager.GetUserWhere(userSelect => userSelect.ID == userRoute.ID);

            nameLabel.Text        = userRoute.Name;
            ageLabel.Text         = "Age: " + userRoute.Age;
            phoneLabel.Text       = "Phone: " + userRoute.Phone;
            descriptionLabel.Text = route.Comments;
            departureLabel.Text   = "Departure: \n" + route.Depart_Date.ToString("dd/MMMM H:mm ") + "h";

            Reservations reservation = new Reservations
            {
                ID_Route = route.ID
            };

            List <Reservations> reservations = await reservationsManager.GetReservationsWhere(reserv => reserv.ID_Route == reservation.ID_Route);

            seatsLabel.Text = "Seats Available: " + (route.Capacity - reservations.Count);

            this.IsBusy = false;
        }