示例#1
0
 static async Task EditCountry(EditCountry obj)
 {
     var                 json                = JsonConvert.SerializeObject(obj);
     var                 httpContent         = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
     HttpClient          client              = new HttpClient();
     HttpResponseMessage httpResponseMessage = await client.PostAsync("http://localhost:2794/EditCountry", httpContent);
 }
示例#2
0
        private async void BtnSave_ClickAsync(object sender, EventArgs e)
        {
            if (EditOrSave == false)
            {
                if (dictionar == "DictionaryCountry")
                {
                    try {
                        AddCountry obj = new AddCountry
                        {
                            Code = textBox1.Text,
                            Name = textBox2.Text
                        }; await AddCountry(obj);
                    }
                    catch
                    {
                        SetBalloonTip("Already Exists", "There is a Country with this name");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }

                    form4.RefreshLists("DictionaryCountry");
                    form4.Enabled = true;
                    this.Close();
                }
                else if (dictionar == "Speaker")
                {
                    try
                    {
                        AddSpeaker obj = new AddSpeaker
                        {
                            Email       = textBox1.Text,
                            Name        = textBox2.Text,
                            Nationality = textBox3.Text
                        }; await AddSpeaker(obj);
                    }
                    catch
                    {
                        SetBalloonTip("Already Exists", "There is a Speaker with this name");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("Speaker");
                    form4.Enabled = true;
                    this.Close();
                }
                else if (dictionar == "DictionaryCounty")
                {
                    try
                    {
                        AddCounty obj = new AddCounty
                        {
                            Code    = textBox1.Text,
                            Name    = textBox2.Text,
                            country = DetailEvent.DictionaryCountryId.ToString()
                        }; await AddCounty(obj);
                    }
                    catch {
                        SetBalloonTip("Already Exists", "There is a County with this name");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("DictionaryCounty");
                    form4.Enabled = true;
                    this.Close();
                }
                else if (dictionar == "DictionaryCity")
                {
                    try
                    {
                        AddCity obj = new AddCity
                        {
                            Code   = textBox1.Text,
                            Name   = textBox2.Text,
                            county = DetailEvent.DictionaryCountyId.ToString()
                        }; await AddCity(obj);
                    }
                    catch
                    {
                        SetBalloonTip("Already Exists", "There is a City with this name");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("DictionaryCity");
                    form4.Enabled = true;
                    this.Close();
                }
                else if (dictionar == "DictionaryCategory")
                {
                    try { await AddCategory(textBox2.Text); }
                    catch {
                        SetBalloonTip("Already Exists", "There is a Category with this name");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("DictionaryCategory");
                    form4.Enabled = true;
                    this.Close();
                }
                else if (dictionar == "DictionaryType")
                {
                    try
                    {
                        AddType obj = new AddType
                        {
                            Name     = textBox2.Text,
                            isRemote = checkBox1.Checked
                        }; await AddType(obj);
                    }
                    catch {
                        SetBalloonTip("Already Exists", "There is a Type with this name");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("DictionaryType");
                    form4.Enabled = true;
                    this.Close();
                }
            }
            else if (EditOrSave == true)
            {
                if (dictionar == "DictionaryCountry")
                {
                    try {
                        EditCountry obj = new EditCountry {
                            Id   = DetailEvent.DictionaryCountryId,
                            Code = textBox1.Text,
                            Name = textBox2.Text
                        }; await EditCountry(obj);
                    }
                    catch {
                        SetBalloonTip("Already Exists", "There is a Country with this name");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("DictionaryCountry");
                    form4.Enabled = true;
                    this.Close();
                }
                else if (dictionar == "Speaker")
                {
                    try {
                        EditSpeaker obj = new EditSpeaker {
                            Name        = textBox2.Text,
                            Email       = textBox1.Text,
                            Id          = DetailEvent.SpeakerId,
                            Nationality = textBox3.Text
                        };
                        await EditSpeaker(obj);
                    }
                    catch {
                        SetBalloonTip("Please insert a valid mail", "Invalid Email");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("Speaker");
                    form4.Enabled = true;
                    this.Close();
                }
                else if (dictionar == "DictionaryCounty")
                {
                    try
                    {
                        EditCounty obj = new EditCounty
                        {
                            Id   = DetailEvent.DictionaryCountyId,
                            Name = textBox2.Text,
                            Code = textBox1.Text
                        }; await EditCounty(obj);
                    }

                    catch {
                        SetBalloonTip("Error", "There was a problem");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("DictionaryCounty");
                    form4.Enabled = true;
                    this.Close();
                }
                else if (dictionar == "DictionaryCity")
                {
                    try
                    {
                        EditCity obj = new EditCity
                        {
                            Name = textBox2.Text,
                            Code = textBox1.Text,
                            Id   = DetailEvent.DictionaryCityId
                        };
                        await EditCity(obj);
                    }
                    catch {
                        SetBalloonTip("Error", "There was a problem");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("DictionaryCity");
                    form4.Enabled = true;
                    this.Close();
                }
                else if (dictionar == "DictionaryCategory")
                {
                    try { EditCategory obj = new EditCategory {
                              id   = DetailEvent.DictionaryConferenceCategoryId,
                              Name = textBox2.Text
                          };
                          await EditCategory(obj); }
                    catch {
                        SetBalloonTip("Error", "There was a problem");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("DictionaryCategory");
                    form4.Enabled = true;
                    this.Close();
                }
                else if (dictionar == "DictionaryType")
                {
                    try { EditType obj = new EditType {
                              Name     = textBox2.Text,
                              id       = DetailEvent.ConferenceTypeId,
                              isRemote = checkBox1.Checked
                          }; await EditType(obj); }
                    catch {
                        SetBalloonTip("Error", "There was a problem");
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(3000);
                    }
                    form4.RefreshLists("DictionaryType");
                    form4.Enabled = true;
                    this.Close();
                }
            }
        }
示例#3
0
 public IActionResult EditCountry([FromBody] EditCountry obj)
 {
     _countryRepository.EditCountry(obj.Id, obj.Code, obj.Name);
     return(Ok());
 }