Esempio n. 1
0
        async void OnDismiss(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            button.IsEnabled = false;
            this.IsBusy      = true;
            try
            {
                string name    = nameCell.Text;
                string cuisine = descriptionCell.Text;

                if (string.IsNullOrWhiteSpace(name) ||
                    string.IsNullOrWhiteSpace(cuisine))
                {
                    this.IsBusy = false;
                    await this.DisplayAlert("Missing Information",
                                            "You must enter values.",
                                            "OK");
                }
                else
                {
                    if (existingclub != null)
                    {
                        existingclub.Name        = name;
                        existingclub.Description = cuisine;

                        await manager.Update(existingclub);

                        int pos = clubs.IndexOf(existingclub);
                        clubs.RemoveAt(pos);
                        clubs.Insert(pos, existingclub);
                    }
                    else
                    {
                        Clubs club = await manager.Add(name, cuisine);

                        clubs.Add(club);
                    }

                    await Navigation.PopModalAsync();
                }
            }
            finally
            {
                this.IsBusy      = false;
                button.IsEnabled = true;
            }
        }