Ejemplo n.º 1
0
 public BlogPost CreateBlogPost(BlogPost blogPost)
 {
     using (var session = _documentStore.OpenSession())
     {
         blogPost.Published = DateTime.UtcNow;
         session.Store(blogPost);
         session.SaveChanges();
     }
     return blogPost;
 }
Ejemplo n.º 2
0
        public ActionResult Create(BlogPost blogPost)
        {
            ActionResult actionResult;

            try
            {
                if (blogPost.IsNew)
                {
                    _blogPostService.CreateBlogPost(blogPost);
                    actionResult = RedirectToAction("Index", "Home");
                }
                else
                {
                    actionResult = new HttpStatusCodeResult(HttpStatusCode.Conflict);
                }
            }
            catch (Exception)
            {
                actionResult = new HttpStatusCodeResult(HttpStatusCode.InternalServerError);
            }

            return actionResult;
        }