App.Core.Controllers.PostsController.Update C# (CSharp) Method

Update() public method

public Update ( Post post, int authorId ) : System.Web.Mvc.ActionResult
post Post
authorId int
return System.Web.Mvc.ActionResult
        public ActionResult Update(Post post, int authorId)
        {
            if (ModelState.IsValid) {
                post.Author = new Account { Id = authorId };
                repository.Save(post);
                return RedirectToAction("Show", post.Id);
            }

            ViewBag.Authors = repository.FindAll<Account>();
            var refreshedPost = repository.Find<Post>(x => x.Id == post.Id);

            return View("Edit", new { post = refreshedPost });
        }