public BlogPost CreateBlogPost(BlogPost blogPost) { using (var session = _documentStore.OpenSession()) { blogPost.Published = DateTime.UtcNow; session.Store(blogPost); session.SaveChanges(); } return blogPost; }
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; }