public ActionResult ConfirmUnPublish(int id, ConfirmPublishModel model) { var post = _postRepository.GetBy(p => p.Id == id); if (post == null) { throw new HttpException((int)HttpStatusCode.NotFound, "The specified post was not found"); } if (ModelState.IsValid) { post.DraftTitle = post.Title; post.DraftDescription = post.Description; post.DraftBody = post.Body; post.Status = PostStatus.Unpublished; var pm = PostModification.GetUnmodifiedPostModification(); pm.PostId = id; pm.StatusModified = true; pm.NewStatus = PostStatus.Unpublished; _postModificationRepository.Create(pm); _postRepository.Update(post); return Json(new { success = true }); } return PartialView("ConfirmUnPublishModal", model); }
public ActionResult ConfirmPublish(int id, ConfirmPublishModel model) { var post = _postRepository.PostsForBlog(CurrentBlog.Id).Single(p => p.Id == id); if (post == null) { throw new HttpException((int)HttpStatusCode.NotFound, "The specified post was not found"); } if (ModelState.IsValid) { //We want to update the published date if we are publishing for the first time if (post.Status == PostStatus.Draft) { post.Posted = _dateTime.Now; } post.Status = PostStatus.Published; post.Title = post.DraftTitle; post.Description = post.DraftDescription; post.Body = post.DraftBody; post.DraftBody = null; post.DraftDescription = null; post.DraftTitle = null; var pm = PostModification.GetUnmodifiedPostModification(_dateTime.Now); pm.PostId = id; pm.StatusModified = true; pm.NewStatus = PostStatus.Published; _postModificationRepository.Create(pm); _postRepository.Update(post); return Json(new { success = true }); } return PartialView("ConfirmPublishModal", model); }