private async Task LoadReservation() { string id_user = currentUser.ID; string id_route = route.ID; Reservations reservation = new Reservations { ID_User = id_user, ID_Route = id_route }; reservationResult = await reservationsManager.GetReservationsWhere(res => res.ID_Route == reservation.ID_Route); if (reservationResult.Count != 0) { foreach (var res in reservationResult) { usersList.Add(await usersManager.GetUserWhere(user => user.ID == res.ID_User)); } foreach (var user in usersList) { usersLayout.Children.Add(new Label() { Text = user.Name }); } } else { usersLayout.Children.Add(new Label() { Text = "Any user reserved" }); } }
async void EmailTextChanged(object sender, EventArgs e) { Entry emailEntry = (Entry)sender; string email = this.emailEntry.Text; if (!string.IsNullOrEmpty(email)) { this.emailEntry.PlaceholderColor = this.emailEntry.TextColor = Color.FromHex("#00695C"); this.activityIndicator.IsRunning = true; validationLabel.IsVisible = true; signUpButton.IsEnabled = false; Users usersSelect = await manager.GetUserWhere(userSelect => userSelect.Email == email); this.emailEntryError.IsVisible = usersSelect != null ? true : false; signUpButton.IsEnabled = usersSelect != null? true: false; this.signUpButton.IsEnabled = !emailEntryError.IsVisible; this.activityIndicator.IsRunning = false; validationLabel.IsVisible = false; } }
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; }
async void SignIn(object sender, EventArgs e) { string email = this.emailEntry.Text; string password = this.passwordEntry.Text; var user = new Users { Email = email, Password = password }; if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password)) { activityIndicator.IsRunning = true; Users userResponse = await usersManager.GetUserWhere(userSelect => userSelect.Email == user.Email && userSelect.Password == user.Password); activityIndicator.IsRunning = false; if (userResponse != null && userResponse.Email.Equals(email, StringComparison.Ordinal) && userResponse.Password.Equals(password, StringComparison.Ordinal)) { Application.Current.Properties["user"] = userResponse; Application.Current.MainPage = new NavigationPage(new Dashboard()); } else { await DisplayAlert("Incorrect", "Your email or password is incorrect, please try again.", "Close"); this.emailEntry.Text = ""; this.passwordEntry.Text = ""; } } else { await DisplayAlert("Incorrect", "The fields Email or Password can't be empty, please insert valid values.", "Close"); this.emailEntry.Text = ""; this.passwordEntry.Text = ""; } }