async void Edit_Place(object sender, EventArgs e)
        {
            MenuItem          item     = (MenuItem)sender;
            SlotsView         slotView = item.CommandParameter as SlotsView;
            PlacesApiServices service  = new PlacesApiServices();
            Place             place    = await service.GetPlaceByIdAsync(Settings.AccessToken, Int32.Parse(slotView.PlaceId.ToString()));

            await Navigation.PushAsync(new EditPlacePage(place));
        }
        async void DeleteItem_Clicked(object sender, EventArgs e)
        {
            MenuItem  item = (MenuItem)sender;
            SlotsView slot = item.CommandParameter as SlotsView;

            if (slot != null)
            {
                if (await this.DisplayAlert("Delete Place?",
                                            "Are you sure you want to delete the Place '"
                                            + slot.PlaceName + "'?", "Yes", "Cancel") == true)
                {
                    PlacesApiServices service = new PlacesApiServices();
                    await service.DeletePlaceAsync(Settings.AccessToken, slot.PlaceId.ToString());

                    MyPageName.IsPullToRefreshEnabled = true;
                }
            }
        }
Exemple #3
0
        public SlotPage(SlotsView slotsView)
        {
            //InitializeComponent ();
            System.Diagnostics.Debug.WriteLine("sots data" + slotsView.PlaceName);
            //}

            this.slotsView = slotsView;

            Button button = new Button()
            {
                BackgroundColor = Color.Gray,
                TextColor       = Color.White,
                Text            = "Update",
                BorderRadius    = 0,
            };

            topLabel = new Label
            {
                Text            = slotsView.PlaceName,
                TextColor       = Color.Black,
                FontSize        = 50,
                HeightRequest   = 70,
                BackgroundColor = Color.Gray
            };
            Button myButton1 = new Button {
                Text = "-", FontSize = 50
            };

            label = new Label
            {
                Text                    = slotsView.FreeSlots.ToString(),
                FontSize                = 50,
                WidthRequest            = 150,
                HeightRequest           = 50,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                BackgroundColor         = Color.Gray
            };
            Button myButton2 = new Button {
                Text = "+", FontSize = 50
            };

            StackLayout myStackLayout = new StackLayout
            {
                Children =
                {
                    myButton1,
                    label,
                    myButton2
                },
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                HeightRequest     = 100,
            };

            //button.Clicked += OnDismiss;
            button.Clicked    += OnUpdateButtonClicked;
            myButton1.Clicked += MyButton1Clicked;
            myButton2.Clicked += MyButton2Clicked;

            void MyButton2Clicked(object sender, EventArgs e)
            {
                label.Text = (Int32.Parse(label.Text) + 1).ToString();
            }

            void MyButton1Clicked(object sender, EventArgs e)
            {
                label.Text = (Int32.Parse(label.Text) - 1).ToString();
            }

            Content = new StackLayout
            {
                Spacing = 10,
                //Children = { tableView, button },
                Children = { topLabel, myStackLayout, button },
            };
        }