public async Task <IActionResult> Edit(int id, [Bind("PostId,Topic,Text,ParentPostId")] 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(nameof(Index))); } ViewData["ParentPostId"] = new SelectList(_context.Posts, "PostId", "PostId", post.ParentPostId); return(View(post)); }
public async Task <IActionResult> Edit(int id, [Bind("CourseId,Name,Prefix,Number")] Course course) { if (id != course.CourseId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(course); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(course.CourseId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(course)); }