public async Task <IActionResult> Edit(int id, [Bind("IDRap,TenRap,TrangThai,IDTP")] RapModel rapModel) { if (id != rapModel.IDRap) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rapModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RapModelExists(rapModel.IDRap)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IDTP"] = new SelectList(_context.ThanhPho, "IDTP", "IDTP", rapModel.IDTP); return(View(rapModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdRap,TenRap,DiaChiRap,MaQuanHuyen")] RapModel rapModel) { if (id != rapModel.IdRap) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rapModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RapModelExists(rapModel.IdRap)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaQuanHuyen"] = new SelectList(_context.quanHuyenModels, "IdQuanHuyen", "TenQuanHuyen", rapModel.MaQuanHuyen); return(View(rapModel)); }
public async Task <IActionResult> Create([Bind("IdRap,TenRap,DiaChiRap,MaQuanHuyen")] RapModel rapModel) { if (ModelState.IsValid) { _context.Add(rapModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaQuanHuyen"] = new SelectList(_context.quanHuyenModels, "IdQuanHuyen", "TenQuanHuyen", rapModel.MaQuanHuyen); return(View(rapModel)); }
public async Task <IActionResult> Create([Bind("IDRap,TenRap,TrangThai,IDTP")] RapModel rapModel) { if (ModelState.IsValid) { _context.Add(rapModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IDTP"] = new SelectList(_context.ThanhPho, "IDTP", "IDTP", rapModel.IDTP); return(View(rapModel)); }