Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async void search_click(object sender, RoutedEventArgs e)
- {
- MobileServiceCollection<UserData, UserData> data;
- IMobileServiceTable<UserData> dataTable = App.MobileService.GetTable<UserData>();
- try
- {
- showBlock.Text = "searching.....";
- statusBar.IsIndeterminate = true;
- searchButton.IsEnabled = false;
- if (searchBox.Text != "")
- {
- tempUnamePhone = await App.MobileService.GetTable<UserData>().Where(x => x.uname == searchBox.Text || x.phone == searchBox.Text).ToListAsync();
- data = await dataTable.Where(x => x.uname == searchBox.Text).Select(x=>x.fname).ToCollectionAsync();
- }
- if (tempUnamePhone.Count != 0)
- {
- showBlock.Text = "item found"+fname;
- statusBar.IsIndeterminate = false;
- searchButton.IsEnabled = true;
- }
- else
- {
- showBlock.Text = "no match found";
- statusBar.IsIndeterminate = false;
- searchButton.IsEnabled = true;
- }
- }
- catch (Exception )
- {
- var m = new MessageDialog("Network error..close the app and try again" ).ShowAsync();
- }
- }
- }
- var fname = string.Empty;
- if (searchBox.Text != "")
- {
- tempUnamePhone = await App.MobileService.GetTable<UserData>().Where(x => x.uname == searchBox.Text || x.phone == searchBox.Text).ToListAsync();
- fname =tempUnamePhone.Where(x => x.uname == searchBox.Text).FirstOrDefault() == null ? string.Empty : await dataTable.Where(x => x.uname == searchBox.Text).First().fname;
- if (tempUnamePhone.Count != 0)
- {
- showBlock.Text = "item found" + fname;
- statusBar.IsIndeterminate = false;
- searchButton.IsEnabled = true;
- }
- else
- {
- showBlock.Text = "no match found";
- statusBar.IsIndeterminate = false;
- searchButton.IsEnabled = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement