Esempio n. 1
0
        public ActionResult Post(EditPostViewModel model)
        {
            var postId = BlogService.CreateOrUpdatePost(new Models.PostModel
            {
                BlogId = model.BlogId.Value,
                Body = model.Body,
                Identifier = model.Identifier,
                PostId = model.PostId,
                Title = model.Title,
                UrlTitle = model.UrlTitle,
                PublishDate = model.PublishDate,
                IsDraft = model.IsDraft
            });

            return RedirectToAction("Posts");
        }
Esempio n. 2
0
 public PartialViewResult PreviewMarkdown(EditPostViewModel model)
 {
     var result = new Post
     {
         Title = model.Title,
         PostDate = DateTime.UtcNow,
         RawBody = model.Body
     };
     return PartialView("../Blog/Post", result);
 }
Esempio n. 3
0
        public ActionResult Post(int? postId)
        {
            EditPostViewModel viewModel;
            if (postId.HasValue)
            {
                var model = BlogService.GetPost(postId.Value);
                viewModel = new EditPostViewModel
                {
                    Body = model.Body,
                    CreatedDate = model.CreatedDate,
                    Identifier = model.Identifier,
                    ModifedDate = model.ModifedDate,
                    PostId = model.PostId,
                    Title = model.Title,
                    BlogId = model.BlogId,
                    UrlTitle = model.UrlTitle,
                    PublishDate = model.PublishDate,
                    IsDraft = model.IsDraft
                };
            }
            else
            {
                viewModel = new EditPostViewModel
                {
                    PostId = null,
                    Identifier = Guid.NewGuid(),
                    BlogId = null
                };
            }

            return View(viewModel);
        }