Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. private async void search_click(object sender, RoutedEventArgs e)
  2. {
  3. MobileServiceCollection<UserData, UserData> data;
  4. IMobileServiceTable<UserData> dataTable = App.MobileService.GetTable<UserData>();
  5.  
  6. try
  7. {
  8. showBlock.Text = "searching.....";
  9. statusBar.IsIndeterminate = true;
  10. searchButton.IsEnabled = false;
  11. if (searchBox.Text != "")
  12. {
  13. tempUnamePhone = await App.MobileService.GetTable<UserData>().Where(x => x.uname == searchBox.Text || x.phone == searchBox.Text).ToListAsync();
  14. data = await dataTable.Where(x => x.uname == searchBox.Text).Select(x=>x.fname).ToCollectionAsync();
  15.  
  16.  
  17. }
  18. if (tempUnamePhone.Count != 0)
  19. {
  20. showBlock.Text = "item found"+fname;
  21. statusBar.IsIndeterminate = false;
  22. searchButton.IsEnabled = true;
  23. }
  24. else
  25. {
  26.  
  27. showBlock.Text = "no match found";
  28.  
  29. statusBar.IsIndeterminate = false;
  30. searchButton.IsEnabled = true;
  31. }
  32. }
  33. catch (Exception )
  34. {
  35. var m = new MessageDialog("Network error..close the app and try again" ).ShowAsync();
  36. }
  37.  
  38. }
  39. }
  40.  
  41. var fname = string.Empty;
  42. if (searchBox.Text != "")
  43. {
  44. tempUnamePhone = await App.MobileService.GetTable<UserData>().Where(x => x.uname == searchBox.Text || x.phone == searchBox.Text).ToListAsync();
  45. fname =tempUnamePhone.Where(x => x.uname == searchBox.Text).FirstOrDefault() == null ? string.Empty : await dataTable.Where(x => x.uname == searchBox.Text).First().fname;
  46.  
  47. if (tempUnamePhone.Count != 0)
  48. {
  49. showBlock.Text = "item found" + fname;
  50. statusBar.IsIndeterminate = false;
  51. searchButton.IsEnabled = true;
  52. }
  53. else
  54. {
  55.  
  56. showBlock.Text = "no match found";
  57.  
  58. statusBar.IsIndeterminate = false;
  59. searchButton.IsEnabled = true;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement