예제 #1
0
        private void AdoptButton_TouchDown(object sender, EventArgs e)
        {
            //Create Alert
            var okCancelAlertController = UIAlertController.Create("Do you want to adopt?", "For a short amount of $200 you can adopt this animal.", UIAlertControllerStyle.Alert);

            //Add Actions
            okCancelAlertController.AddAction(UIAlertAction.Create("Adopt", UIAlertActionStyle.Default, alert => {
                Console.WriteLine("Okay was clicked");
                selectedAnimal.Owner = "JunctionX";
                MyAnimalsViewModel.AddAnimal(selectedAnimal);
                if (selectedAnimal.Owner == null || selectedAnimal.Owner == "")
                {
                    AdoptView.Hidden    = true;
                    ButtonsView1.Hidden = false;
                    ButtonsView2.Hidden = true;
                }
                else
                {
                    AdoptView.Hidden    = false;
                    ButtonsView1.Hidden = true;
                    ButtonsView2.Hidden = false;
                }

                OwnerLabel.Text = selectedAnimal.Owner;
            }));
            okCancelAlertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, alert => Console.WriteLine("Cancel was clicked")));

            //Present Alert
            PresentViewController(okCancelAlertController, true, null);
        }
예제 #2
0
        private async Task LoadAnimals()
        {
            try
            {
                Items.Value = await backend.GetAnimals();

                if (Items.Value != null && !animalLoaded)
                {
                    foreach (var item in Items.Value)
                    {
                        if (item.Owner == "JunctionX")
                        {
                            MyAnimalsViewModel.AddAnimal(item);
                        }
                    }
                    animalLoaded = true;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }