public async Task <IActionResult> Edit(int id, [Bind("Id,BuyerId,Name,City,Addr,Phone,IsDef")] BbsAddr bbsAddr) { if (id != bbsAddr.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bbsAddr); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BbsAddrExists(bbsAddr.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BuyerId"] = new SelectList(_context.BbsBuyer, "Username", "Username", bbsAddr.BuyerId); return(View(bbsAddr)); }
public async Task <IActionResult> Create([Bind("Id,BuyerId,Name,City,Addr,Phone,IsDef")] BbsAddr bbsAddr) { if (ModelState.IsValid) { _context.Add(bbsAddr); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BuyerId"] = new SelectList(_context.BbsBuyer, "Username", "Username", bbsAddr.BuyerId); return(View(bbsAddr)); }