private MenuOptionResult RemoveCity() { // Prompt the user for a city name string cityName = GetString("Enter the name of the city to remove: "); // Call the DAO to Delete a city by name int rowsDeleted = cityDAO.DeleteCity(cityName, country.Code); if (rowsDeleted == 0) { Console.WriteLine($"City {cityName}, {country.Code} was not found, and therefore not deleted."); } else { Console.WriteLine($"City {cityName}, {country.Code} was deleted."); } return(MenuOptionResult.WaitAfterMenuSelection); }
// TODO: Protect City/Delete with AuthorizeFilter so the user must be logged in (Admin) public IActionResult Delete(City city) { // Get the city city = cityDAO.GetCityById(city.CityId); if (city == null) { return(NotFound()); } // Delete the city cityDAO.DeleteCity(city.CityId); // Redirect from delete to search, passing Country and District in CitySearchVM vm = new CitySearchVM(GetCurrentUser()) { CountryCode = city.CountryCode, District = city.District }; // Store a message in TempData to be shown to the user TempData["message"] = $"The city '{city.Name}' was deleted."; return(RedirectToAction("Search", vm)); }
public IActionResult DeleteCity(int id) { cityDAO.DeleteCity(id); return(Ok()); }
public IActionResult Delete(City city) { cityDAO.DeleteCity(city.CityId); return(RedirectToAction("ConfirmDelete")); }
public IActionResult Delete(City city) { cityDAO.DeleteCity(city.CityId); return View(); }