Ejemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);
            Button button2 = FindViewById<Button>(Resource.Id.LoadDB);
            cName = FindViewById<TextView>(Resource.Id.countryName);
            nation = FindViewById<TextView>(Resource.Id.nationality);
            capital = FindViewById<TextView>(Resource.Id.capital);
            population = FindViewById<TextView>(Resource.Id.population);
            currency = FindViewById<TextView>(Resource.Id.currency);
            region = FindViewById<TextView>(Resource.Id.region);
            subregion = FindViewById<TextView>(Resource.Id.subregion);

            button.Click += delegate
            {
                var restProcessor = new RestProcessor();
                restProcessor.GetCountry();
            };

            button2.Click += delegate
            {
                var repo = new DataRepository();
                var country = repo.GetCountry("London");

                if (country != null)
                {
                    cName.Text = "Country Name  ->  " + country.Name;
                    nation.Text = nation.Text + country.Nationality;
                    capital.Text = capital.Text + country.Capital;
                    population.Text = population.Text + country.Population;
                    currency.Text = currency.Text + country.Currency;
                    region.Text = region.Text + country.Region;
                    subregion.Text = subregion.Text + country.Subregion;
                }
                else
                {
                    cName.Text = "Country not found.";
                }
            };
        }
        private void LoadData_OnClick(object sender, RoutedEventArgs e)
        {
            var repo = new DataRepository();
            var country = repo.GetCountry("London");

            if (country != null)
            {
                CountryName.Text = country.Name;
                Nationality.Text = country.Nationality;
                Capital.Text = country.Capital;
                Population.Text = country.Population;
                Currency.Text = country.Currency;
                Region.Text = country.Region;
                Subregion.Text = country.Subregion;
            }
            else
            {
                CountryName.Text = "Country not found.";
            }
        }