Esempio n. 1
0
        private async void FavoriteButton_Click(object sender, RoutedEventArgs e)
        {
            var Item = this.DefaultViewModel[Restaurant] as Restaurant;

            var statusBar = StatusBar.GetForCurrentView();

            statusBar.ProgressIndicator.Text          = ResourceLoader.GetForCurrentView("Resources").GetString("UpdateMessage");
            statusBar.ProgressIndicator.ProgressValue = null;
            await statusBar.ProgressIndicator.ShowAsync();

            this.FavoriteButton.IsEnabled = false;

            if (Item.RestaurantSocial.FavoriteId == -1)
            {
                bool isSuccess = await RestaurantPageSource.AddToFavoriteAsync(Item.Id);

                await statusBar.ProgressIndicator.HideAsync();

                if (isSuccess)
                {
                    ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("FavoriteSuccessfulAdding"));
                }
                else
                {
                    ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("ErrorMessage"));
                }

                FavoriteButtonToggle();
            }
            else
            {
                bool isSuccess = await RestaurantPageSource.RemoveFromFavoriteAsync(Item.Id);

                await statusBar.ProgressIndicator.HideAsync();

                if (isSuccess)
                {
                    ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("FavoriteSuccessfulRemoving"));
                }
                else
                {
                    ShowMessageAsync(ResourceLoader.GetForCurrentView("Resources").GetString("ErrorMessage"));
                }

                FavoriteButtonToggle();
            }

            this.FavoriteButton.IsEnabled = true;
        }
Esempio n. 2
0
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            int Id   = (int)e.NavigationParameter;
            var Item = await RestaurantPageSource.GetRestaurantAsync(Id);

            this.ProgressRing.IsActive = false;

            if (Item == null)
            {
                if (Frame.CanGoBack)
                {
                    Frame.GoBack();

                    await ShowErrorAsync();
                }
                else
                {
                    if (!Frame.Navigate(typeof(MainPage), "FoodLook 2"))
                    {
                        throw new Exception();
                    }
                    Frame.BackStack.Clear();

                    await ShowErrorAsync();
                }
            }
            else
            {
                this.DefaultViewModel[Restaurant] = Item;
                this.DefaultViewModel[Label]      = Item.Label;

                LikeButtonToggle();
                FavoriteButtonToggle();

                this.RestaurantPageCommandBar.Visibility = Visibility.Visible;

                if (Item.Website == null)
                {
                    this.WebsiteBlock.Visibility = Visibility.Collapsed;
                }
                if (Item.Email == null)
                {
                    this.EmailBlock.Visibility = Visibility.Collapsed;
                }
                if (Item.Facebook == null)
                {
                    this.FacebookBlock.Visibility = Visibility.Collapsed;
                }
                if (Item.Instagram == null)
                {
                    this.InstagramBlock.Visibility = Visibility.Collapsed;
                }
                if (!Item.Parking)
                {
                    this.ParkingImage.Opacity = 0.4;
                }
                if (!Item.PaymentCards)
                {
                    this.PaymentCardsImage.Opacity = 0.4;
                }
                if (!Item.LiveMusic)
                {
                    this.LiveMusicImage.Opacity = 0.4;
                }
                if (Item.Telephone == null)
                {
                    this.PhoneButton.Visibility = Visibility.Collapsed;
                }

                this.RestaurantPagePivot.Visibility = Visibility.Visible;
            }
        }