public async Task <IActionResult> Edit(int id, [Bind("Id,State,City")] SelectedCityState selectedCityState) { if (id != selectedCityState.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(selectedCityState); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SelectedCityStateExists(selectedCityState.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(selectedCityState)); }
// GET: SelectedCityStates/Create public IActionResult Create() { SelectedCityState selectedCityStateToEdit = new SelectedCityState(); SetStateCityViewBags(); return(View(selectedCityStateToEdit)); }
public async Task <IActionResult> Create([Bind("Id,State,City")] SelectedCityState selectedCityState) { if (ModelState.IsValid) { _context.Add(selectedCityState); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(selectedCityState)); }