private async void AddCountryFromButton_Click(object sender, EventArgs e)
        {
            System.Text.RegularExpressions.Regex name = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z]+$");

            if (!name.IsMatch(CoutryNameTb.Text))
            {
                errorProviderCountryName.SetError(CoutryNameTb, "The name should contain only letters");
            }
            else
            {
                errorProviderCountryName.SetError(CoutryNameTb, "");
            }

            if (!name.IsMatch(CountryCodTb.Text))
            {
                errorProviderCountryCod.SetError(CountryCodTb, "The code should contain only letters");
            }
            else
            {
                errorProviderCountryCod.SetError(CountryCodTb, "");
            }

            if (CoutryNameTb.TextLength == 0)
            {
                errorProviderCountryName.SetError(CoutryNameTb, "You have to introduce the name");
            }
            else
            {
                errorProviderCountryName.SetError(CoutryNameTb, "");
            }

            if (CountryCodTb.TextLength == 0)
            {
                errorProviderCountryCod.SetError(CountryCodTb, "You have to introduce the code");
            }
            else
            {
                errorProviderCountryCod.SetError(CountryCodTb, "");
            }

            if (CoutryNameTb.TextLength <= 3)
            {
                errorProviderCountryName.SetError(CoutryNameTb, "Such country does not exist");
            }
            else
            {
                errorProviderCountryName.SetError(CoutryNameTb, "");
            }

            if (CountryCodTb.TextLength == 1)
            {
                errorProviderCountryCod.SetError(CountryCodTb, "This code is not explicit");
            }
            else
            {
                errorProviderCountryCod.SetError(CountryCodTb, "");
            }


            if (editCountry == null)
            {
                _getCountry.InsertConferenceCountry(CountryCodTb.Text, CoutryNameTb.Text);
                //PostConferenceCountry(getCountryId());
                //InsertData(CountryCodTb.Text, CoutryNameTb.Text);
                this.Close();
            }

            if (editCountry != null)
            {
                _getCountry.UpdateConferenceCountry(CountryCodTb.Text, CoutryNameTb.Text, editCountry.DictionaryCountryId);
                //PostConferenceCountry(CountryCodTb.Text, CoutryNameTb.Text, getCountryId());
                this.Close();
            }
        }
Beispiel #2
0
 public IActionResult InsertCountry(string cod, string name)
 {
     _getCountry.InsertConferenceCountry(cod, name);
     return(Ok());
 }