/// <summary> /// Obsługa naciśnięcia btn OK. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">EventArgs.</param> private void okRadButtonElement_Click(object sender, EventArgs e) { CityService cityService = new CityService(); if (CurrentCity != null) { this.CurrentCity.Name = this.nameTextBox.Text; cityService.ChangeCitiesCountry(this.CurrentCity, this.countryComboBox.Text, this.CountryCollection); AcceptAndClose(); } else { cityService.AddNewCity(this.nameTextBox.Text, this.countryComboBox.Text, this.CountryCollection); } }
public async Task <IHttpActionResult> AddNewCity(CityModel city) { if (city == null) { return(BadRequest("Please provide valid inputs!")); } if (city.DistrictID == 0) { return(BadRequest("Please provide valid district ID!")); } if (string.IsNullOrEmpty(city.Location)) { return(BadRequest("Please provide valid location!")); } if (await AuthService.ValidateUserAndToken(city.Token, city.UserID, city.Email, city.Location)) { if (await CityService.CityExists(city)) { return(BadRequest("City Already Exists")); } else { if (await CityService.AddNewCity(city)) { return(Ok("City Added Successfully!")); } else { return(BadRequest("City Adding Failed!")); } } } else { return(Unauthorized()); } }