Exemplo n.º 1
0
        private async void btnAddDistrict_Click(object sender, EventArgs e)
        {
            var selectedCountry = (CountryResponse)cbOriginCountry.SelectedItem;

            var selectedRegion = (RegionResponse)cbOriginRegion.SelectedItem;


            var addCountryResponse = await Infrastructure.AddDistrict(tbNewDistrict.Text, selectedRegion.RegionId);

            if (addCountryResponse.ErrorCode)
            {
                var metadetaErrorModel = await Infrastructure.GetMetadata();

                MetaDataResponse metadata = (MetaDataResponse)metadetaErrorModel.Object;
                Metadata = metadata;

                ShowCountriesAddNewWine();
                cbOriginCountry.SelectedIndex  = cbOriginCountry.FindStringExact(selectedCountry.CountryName);
                cbOriginRegion.SelectedIndex   = cbOriginRegion.FindStringExact(selectedRegion.RegionName);
                cbOriginDistrict.SelectedIndex = cbOriginDistrict.FindStringExact(tbNewDistrict.Text);
            }
            else if (!string.IsNullOrEmpty(addCountryResponse.Message))
            {
                MessageBox.Show(addCountryResponse.Message, "Fel");
            }
        }