Example #1
0
        public ActionResult Edit(Guid id)
        {
            var post = _postService.Get(id);
            if(post == null) return HttpNotFound();

            var model = new EditPostViewModel()
            {
                Id = post.Id,
                PostContent = post.PostContent,
            };

            return View(model);
        }
Example #2
0
        public ActionResult Edit(EditPostViewModel model)
        {
            if (ModelState.IsValid)
            {
                var post = _postService.Get(model.Id);
                if (post == null) return HttpNotFound();

                post.PostContent = model.PostContent.Trim();
                post.DateEdited = DateTime.UtcNow;

                _postService.Update(post);

                return RedirectToAction("Details", "Topic", new {id = post.ParentTopicId});
            }

            return View(model);
        }