Beispiel #1
0
        private async void onSubmit(object sender, EventArgs e)
        {
            bool isFieldFilled = IsFieldFilled();

            if (isFieldFilled)
            {
                string gender  = (string)cb_gender.SelectedItem;
                string name    = tb_name.Text;
                string surname = tb_surname.Text;
                string email   = tb_email.Text;
                string gsm     = tb_gsm.Text;
                string street  = tb_street.Text;
                string zipcode = tb_zipcode.Text;
                string city    = tb_city.Text;
                string country = tb_country.Text;

                Guarantor guarantor = new Guarantor(null, gender, name, surname, email, gsm);
                guarantor.Address = new Location(street, zipcode, city, country);

                Dictionary <string, object> guarantorDic = Utils.ToDictionnary(guarantor);
                string guarantorJSON = Utils.ToJson(guarantorDic);

                APIRes response = await Utils.Post(@"http://localhost:5000/api/guarantors", guarantorJSON);

                if (response.Success)
                {
                    MessageBox.Show(response.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                MessageBox.Show(response.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private async void onAsyncComboOpen(object sender, EventArgs e)
        {
            if (cb_guarantor.Items.Count == 0)
            {
                cb_guarantor.Items.Add("Chargement ....");
                guarantors = await Utils.Get <Guarantor>(@"http://localhost:5000/api/guarantors/withoutOccupant");

                string guarantorName;
                string GuarantorSurname;
                foreach (Guarantor guarantor in guarantors)
                {
                    guarantorName    = guarantor.Name;
                    GuarantorSurname = guarantor.Surname;

                    cb_guarantor.Items.Add($"{guarantorName} {GuarantorSurname}");
                }
                cb_guarantor.Items.RemoveAt(0);
                if (guarantors.Count > 0)
                {
                    cb_guarantor.SelectedIndex = 0;
                    guarantorSelected          = guarantors[0];
                }
            }
        }
Beispiel #3
0
        private void onComboBoxChange(object sender, EventArgs e)
        {
            int selectedIndex = cb_guarantor.SelectedIndex;

            guarantorSelected = guarantors[selectedIndex];
        }