public async Task <IActionResult> Edit(Guid?forumTopicsId) { if (forumTopicsId == null) { return(NotFound()); } var forumTopic = await _context.ForumTopics.SingleOrDefaultAsync(m => m.Id == forumTopicsId); if (forumTopic == null || !this.userPermissions.CanEditForumTopic(forumTopic)) { return(NotFound()); } var model = new ForumTopicsEditModel { Name = forumTopic.Name }; ViewBag.ForumTopic = forumTopic; return(View(model)); }
public async Task <IActionResult> Edit(Guid?forumTopicsId, ForumTopicsEditModel model) { if (forumTopicsId == null) { return(NotFound()); } var forumTopic = await _context.ForumTopics.SingleOrDefaultAsync(m => m.Id == forumTopicsId); if (forumTopic == null || !this.userPermissions.CanEditForumTopic(forumTopic)) { return(NotFound()); } if (ModelState.IsValid) { DateTime now = DateTime.UtcNow; forumTopic.Name = model.Name; forumTopic.Modified = now; await this._context.SaveChangesAsync(); return(this.RedirectToAction("Details", new { id = forumTopic.Id })); } ViewBag.ForumTopic = forumTopic; return(View(forumTopic)); }