public async Task <IActionResult> Edit(int id, [Bind("Id,Code,Name,City")] BbsTown bbsTown) { if (id != bbsTown.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bbsTown); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BbsTownExists(bbsTown.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bbsTown)); }
public async Task <IActionResult> Create([Bind("Id,Code,Name,City")] BbsTown bbsTown) { if (ModelState.IsValid) { _context.Add(bbsTown); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bbsTown)); }