private async void BtnAdd_Click(object sender, RoutedEventArgs e) { AddCity add = new AddCity(AdminInterface); add.ShowDialog(); await Task.Run(() => RefreshList()); }
public async Task <IActionResult> Post([FromBody] AddCity command) { // await _cityService.AddAsync(command.Name); await _busPublisher.PublishCommandAsync(command); return(Created("cities", null)); }
private async void AddPeople(object obj) { if (AddDateOfBirth == null || AddDateOfBirth.Replace(" ", "").Length == 0) { EmptyFieldMessage(obj as Window, "AddDateOfBirth"); } else if (AddName == null || AddName.Replace(" ", "").Length == 0) { EmptyFieldMessage(obj as Window, "AddName"); } else if (AddLastName == null || AddLastName.Replace(" ", "").Length == 0) { EmptyFieldMessage(obj as Window, "AddLastName"); } else if (AddSurName == null || AddSurName.Replace(" ", "").Length == 0) { EmptyFieldMessage(obj as Window, "AddSurName"); } else if (AddCity == null || AddCity.Replace(" ", "").Length == 0) { EmptyFieldMessage(obj as Window, "AddCity"); } else if (AddCountry == null || AddCountry.Replace(" ", "").Length == 0) { EmptyFieldMessage(obj as Window, "AddCoutry"); } else { using (IRepository <People> Repository = new PeopleRepository()) PeopleCollection = await Repository.CreateObject(new People(DateTime.Parse(AddDateOfBirth).Date, AddName, AddLastName, AddSurName, AddCity, AddCountry)); ClearAddedPeople(); } }
static async Task AddCity(AddCity 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/DictionaryCity/AddCity", httpContent); }
private void addCity_Click(object sender, RoutedEventArgs e) { AddCity addCity = new AddCity(); addCity.mainWindow = this; addCity.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { AddCity addCity = new AddCity(mysqlCSB, nameTrack); addCity.ShowDialog(); LoadCity(); listBox1.Items.Clear(); listBox1.Items.AddRange(CityList.ToArray()); listBox1.Refresh(); }
//-------------------------------------------------------------------------------------------------------- private void button_AddCity_Click(object sender, EventArgs e) { try { getFull?.Invoke(textBoxCity.Text); AddCity?.Invoke(textBoxCity.Text); listBox_City.Focus(); listBox_City.SelectedIndex = listBox_City.FindString(textBoxCity.Text); } catch (WebException exc) { MessageBox.Show(exc.Message, "Error! City not found!", MessageBoxButtons.OK, MessageBoxIcon.Error); } textBoxCity.Text = ""; }
public void AddNewCityIsCalled_WhenParametersAreCorrect(string input, string consoleResult) { //Arrange var parameters = input.Split().ToList(); var cinemaConsoleMock = new Mock <IAlphaCinemaConsole>(); cinemaConsoleMock.Setup(console => console.ReadLineMiddle(It.IsAny <int>(), It.IsAny <int>())).Returns(consoleResult); var unitOfWorkMock = new Mock <IUnitOfWork>(); var cityServiceMock = new Mock <ICityServices>(); //Act var addCity = new AddCity(cityServiceMock.Object, cinemaConsoleMock.Object); var result = addCity.Execute(parameters); //Arrange cityServiceMock.Verify(cityService => cityService.AddNewCity(It.IsAny <string>()), Times.Once); }
public void ReturnCorrectList_WhenCityNameIsValid(string input, string consoleResult, string expected) { //Arrange var parameters = input.Split().ToList(); var cinemaConsoleMock = new Mock <IAlphaCinemaConsole>(); cinemaConsoleMock.Setup(console => console.ReadLineMiddle(It.IsAny <int>(), It.IsAny <int>())).Returns(consoleResult); var unitOfWorkMock = new Mock <IUnitOfWork>(); var cityServiceMock = new Mock <ICityServices>(); //Act var addCity = new AddCity(cityServiceMock.Object, cinemaConsoleMock.Object); var result = addCity.Execute(parameters); //Arrange Assert.AreEqual(expected, result.First()); }
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(); } } }
public IActionResult AddCity([FromBody] AddCity obj) { _cityRepository.AddCity(obj.Code, obj.Name, obj.county); return(Ok()); }
public ActionResult add_city(AddCity AddCity) { var error_message = new object(); if (string.IsNullOrWhiteSpace(AddCity.adminCoSelect) || string.IsNullOrWhiteSpace(AddCity.adminPrSelect) || string.IsNullOrWhiteSpace(AddCity.adminCity)) { error_message = "error, bad request please check inputs"; return(Json(error_message, "application/json; charset=utf-8", Encoding.UTF8, JsonRequestBehavior.DenyGet)); } var countryId = Guid.Parse(AddCity.adminCoSelect); var provinceId = Guid.Parse(AddCity.adminPrSelect); City city = new City { CityName = AddCity.adminCity, CountryId = countryId, ProvinceId = provinceId, Description = AddCity.adminCityDesc }; //add new city bool flag = false; using (var api = new HttpClient()) { api.BaseAddress = new Uri("https://localhost:44343/api/city/"); api.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var post = api.PostAsJsonAsync <City>("new", city); post.Wait(); var result = post.Result; if (result.StatusCode == HttpStatusCode.Created) { var s = result.Content.ReadAsAsync <bool>(); s.Wait(); flag = s.Result; } else if (result.StatusCode == HttpStatusCode.NotFound) { var s = result.Content.ReadAsAsync <bool>(); s.Wait(); flag = s.Result; } else { error_message = "error, internal server error please try again later"; return(Json(error_message, "application/json; charset=utf-8", Encoding.UTF8, JsonRequestBehavior.DenyGet)); } } if (!flag) { error_message = "error, internal server error please try again later"; return(Json(error_message, "application/json; charset=utf-8", Encoding.UTF8, JsonRequestBehavior.DenyGet)); } else { error_message = Url.Action("home", "admin"); return(Json(error_message, "application/json; charset=utf-8", Encoding.UTF8, JsonRequestBehavior.DenyGet)); } }