public async Task <IActionResult> Edit(int id, [Bind("PostId,Title,Username,Question")] Post post) { if (id != post.PostId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(post); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(post.PostId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(post)); }
public async Task <IActionResult> Edit(int id, [Bind("AnswerId,Name,Content,PostId")] Answer answer) { if (id != answer.AnswerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(answer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnswerExists(answer.AnswerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(answer)); }