public async void GetDogsByOwner(string owner) { if ((CrossConnectivity.Current.IsConnected == false)) { var alertResult = await DisplayAlert(Constants.internetAlertTittle, Constants.internetAlertMessage, null, Constants.internetButton); if (!alertResult) { MasterDetailSideMenucs.CreateMasterPage(); await Navigation.PushModalAsync(MasterDetailSideMenucs.MasterDetailPage); } } else { List <Dog> listOfDogs = await manager.CheckOwnerDogs(owner); List <DogAndImage> listOfDogsWithImage = new List <DogAndImage>(); if (listOfDogs != null) { foreach (Dog dog in listOfDogs) { DogAndImage d = new DogAndImage(); d.Dog = dog; Image image = new Image(); if (dog.ImageD != null) { image.Source = ImageSource.FromStream(() => Utils.ImageStream.ConvertStringToStream(dog.ImageD)); } else { image.Source = ImageSource.FromFile("Dog.png"); } d.DogImage = image; listOfDogsWithImage.Add(d); } orderedData = new ObservableCollection <DogAndImage> (listOfDogsWithImage.OrderBy(dog => dog.Dog.DogName).ToList()); BindingContext = orderedData; indicator.IsVisible = false; indicator.IsRunning = false; } } }
public async Task <List <Dog> > GetDogsByOwner(string owner) { if ((CrossConnectivity.Current.IsConnected == false)) { await DisplayAlert(Constants.internetAlertTittle, Constants.internetAlertMessage, null, Constants.internetButton); return(null); } else { List <Dog> listOfDogs = await manager.CheckOwnerDogs(owner); if (listOfDogs == null) { return(null); } return(listOfDogs); } }
async private void CreateNewAccount_Clicked(object sender, EventArgs e) { if ((CrossConnectivity.Current.IsConnected == false)) { await DisplayAlert(Constants.internetAlertTittle, Constants.internetAlertMessage, null, Constants.internetButton); } else { if ((ownerName.Text) == null || userName.Text == null || password.Text == null) { await DisplayAlert("Opps!", "Please enter all details", "OK"); } else { bool sure = await DisplayAlert("Warning", "Are you sure?", "Yes", "No"); if (sure) { activity.IsVisible = true; activity.IsRunning = true; var method = await(manager.CheckIfOwnerAlreadyExists(userName.Text)); if (method != null) { await DisplayAlert("Opps!", "Username is already taken", "OK"); userName.Text = string.Empty; userName.Unfocus(); password.Text = string.Empty; password.Unfocus(); activity.IsVisible = false; activity.IsRunning = false; } else { activity.IsVisible = true; activity.IsRunning = true; var owner = new Owner { OwnerName = ownerName.Text, UserName = userName.Text, Password = password.Text, ImageO = Utils.ImageStream.ConvertStreamToString(memStream) }; if (memStream != null) { memStream.Dispose(); } await AddItem(owner); await SqliteConnectionSet._connection.InsertAsync(owner); SqliteConnectionSet._user.Add(owner); App.currentOwner = owner; bool next = await DisplayAlert("", "Your account added succefully", "OK", "Cancel"); activity.IsVisible = false; activity.IsRunning = false; if (next) { List <Dog> dogsList = await dManager.CheckOwnerDogs(App.currentOwner.OwnerName); if (dogsList != null) { if (dogsList.Count > 1) { await Navigation.PushAsync(new DogList()); } else { await Navigation.PushModalAsync(MasterDetailSideMenucs.MasterDetailPage); } } else { await Navigation.PushAsync(new DogList()); } } } } } } }
public async void Button_Clicked(object sender, EventArgs e) { if ((CrossConnectivity.Current.IsConnected == false)) { await DisplayAlert(Constants.internetAlertTittle, Constants.internetAlertMessage, Constants.internetButton); } else { if (userName.Text == null || password.Text == null) { await DisplayAlert("Oops!", "Please enter Username & password", "OK"); } else { activity.IsVisible = true; activity.IsRunning = true; var method = await(manager.CheckUserNameAndPassword(userName.Text, password.Text)); if (method == null) { await DisplayAlert("Oops!", "The username or password are not valid", "OK"); activity.IsVisible = false; activity.IsRunning = false; userName.Text = string.Empty; userName.Unfocus(); password.Text = string.Empty; password.Unfocus(); } else { App.currentOwner = method; activity.IsVisible = true; activity.IsRunning = true; List <Dog> dogsList = await dManager.CheckOwnerDogs(App.currentOwner.OwnerName); if (SqliteConnectionSet._user.Count == 0) { await SqliteConnectionSet._connection.InsertAsync(method); SqliteConnectionSet._user.Add(method); } if (dogsList != null) { if (dogsList.Count > 1) { await Navigation.PushAsync(new MyDogsPage()); } else { MasterDetailSideMenucs.CreateMasterPage(); await Navigation.PushModalAsync(MasterDetailSideMenucs.MasterDetailPage); } } else { await Navigation.PushAsync(new MyDogsPage()); } } } } }