protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            string id = e.Parameter as string;

            try
            {
                items3 = await Table3.Where(Tour
                                            => Tour.Id == id).ToCollectionAsync();

                string[] ids = items3[0].Scrap_List.Split(',');
                foreach (string item in ids)
                {
                    if (item != "")
                    {
                        items2 = await Table2.Where(Scrap
                                                    => Scrap.Id == item).ToCollectionAsync();

                        m       = new Purchsed();
                        m.Id    = items2[0].Id;
                        m.Title = items2[0].Title;
                        m.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(this.BaseUri, "Assets/augmented-reality-for-blog.jpg")); // static image
                        m.Type  = "S";
                        Tlist.Add(m);
                    }
                }
                TourView.DataContext = Tlist;
            }

            catch (Exception)
            {
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            string id = e.Parameter as string;

            LoadingBar.Visibility      = Visibility.Visible;
            LoadingBar.IsIndeterminate = true;
            try
            {
                items3 = await Table3.Where(Diary
                                            => Diary.Id == id).ToCollectionAsync();

                string[] ids = items3[0].Tour_List.Split(',');
                foreach (string nid in ids)
                {
                    if (nid != "")
                    {
                        items2 = await Table2.Where(Tour
                                                    => Tour.Id == nid).ToCollectionAsync();

                        m       = new Purchsed();
                        m.Id    = items2[0].Id;
                        m.Title = items2[0].Title;
                        m.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(items2[0].Cover_Url));
                        m.Type  = "T";
                        Tlist.Add(m);
                    }
                }
                DiaryView.DataContext = Tlist;
                LoadingBar.Visibility = Visibility.Collapsed;
            }

            catch (Exception)
            {
                MessageDialog msgbox = new MessageDialog("Sorry can't update now");
                await msgbox.ShowAsync();

                LoadingBar.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #3
0
        //private async void data_Update()
        //{

        //    items1 = await Table1.ToCollectionAsync();

        //    foreach(Scrap s in items1)
        //    {
        //        string[] po = s.Point_List.Split(',');
        //        items4 = await Table4.Where(Pointer
        //            => Pointer.Id == po[0]).ToCollectionAsync();
        //        s.lat = items4[0].lat;
        //        s.lon = items4[0].lon;
        //        await Table1.UpdateAsync(s);
        //    }
        //}
        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                LoadingBar2.Visibility      = Visibility.Visible;
                LoadingBar2.IsIndeterminate = true;

                items = await Table.Where(User
                                          => User.Id == userid).ToCollectionAsync(); // get the username from login page

                if (items[0].ScrapePurchase != null)
                {
                    Scrap_Purchases = items[0].ScrapePurchase.Split(',').ToList <string>();
                }
                if (items[0].TourPurchases != null)
                {
                    Tour_Purchases = items[0].TourPurchases.Split(',').ToList <string>();
                }
                if (items[0].DiaryPurchases != null)
                {
                    Diary_Purchases = items[0].DiaryPurchases.Split(',').ToList <string>();
                }
                foreach (string id in Scrap_Purchases)
                {
                    if (id != "")
                    {
                        m      = new Purchsed();
                        items1 = await Table1.Where(Scrap
                                                    => Scrap.Id == id).ToCollectionAsync();

                        m.Id    = items1[0].Id;
                        m.Title = items1[0].Title;
                        m.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(this.BaseUri, "Assets/augmented-reality-for-blog.jpg")); // some static iage for scrap
                        m.Type  = "S";
                        Slist.Add(m);
                    }
                }

                foreach (string id in Tour_Purchases)
                {
                    if (id != "")
                    {
                        m      = new Purchsed();
                        items2 = await Table2.Where(Tour
                                                    => Tour.Id == id).ToCollectionAsync();

                        m.Id    = items2[0].Id;
                        m.Title = items2[0].Title;
                        m.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(items2[0].Cover_Url));
                        m.Type  = "T";
                        Tlist.Add(m);
                    }
                }
                foreach (string id in Diary_Purchases)
                {
                    if (id != "")
                    {
                        m      = new Purchsed();
                        items3 = await Table3.Where(Diary
                                                    => Diary.Id == id).ToCollectionAsync();

                        m.Id    = items3[0].Id;
                        m.Title = items3[0].Title;
                        m.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(items3[0].Cover_Url));
                        m.Type  = "D";
                        Dlist.Add(m);
                    }
                }

                items1 = await Table1.Where(Scrap
                                            => Scrap.UserId == userid).ToCollectionAsync();

                foreach (Scrap sr in items1)
                {
                    m       = new Purchsed();
                    m.Id    = sr.Id;
                    m.Title = sr.Title;
                    m.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(this.BaseUri, "Assets/augmented-reality-for-blog.jpg")); // some static iage for scrap
                    m.Type  = "S";
                    Slist.Add(m);
                }

                items2 = await Table2.Where(Tour
                                            => Tour.UserId == userid).ToCollectionAsync();

                foreach (Tour sr in items2)
                {
                    m = new Purchsed();

                    m.Id    = sr.Id;
                    m.Title = sr.Title;
                    m.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(sr.Cover_Url)); // some static iage for scrap
                    m.Type  = "T";
                    Tlist.Add(m);
                }

                items3 = await Table3.Where(Diary
                                            => Diary.UserId == userid).ToCollectionAsync();

                foreach (Diary sr in items3)
                {
                    m       = new Purchsed();
                    m.Id    = sr.Id;
                    m.Title = sr.Title;
                    m.Image = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(sr.Cover_Url)); // some static iage for scrap
                    m.Type  = "D";
                    Dlist.Add(m);
                }

                LoadingBar2.Visibility = Visibility.Collapsed;
                DiaryView.DataContext  = Dlist;
                TourView.DataContext   = Tlist;
                ScarpeView.DataContext = Slist;
            }
            catch (Exception)
            {
                MessageDialog msgbox = new MessageDialog("Sorry can't update now");
                await msgbox.ShowAsync();

                LoadingBar2.Visibility = Visibility.Collapsed;
            }
        }