Ejemplo n.º 1
0
 public ActionResult NewPost(FormCollection formCollection)
 {
     BlogPost blogPost = new BlogPost();
     TryUpdateModel<INewBlogPost>(blogPost, formCollection);
     blogPost.PostedDate = DateTime.UtcNow;
     blogPost.Author = User.Identity.Name;
     if (!ModelState.IsValid)
     {
         ViewBag.FormTitle = "New Post";
         return View("ManagePost");
     }
     _blogPostRepository.AddBlogPost(blogPost);
     _blogPostRepository.SaveChanges();
     return RedirectToAction("Post", new { Id = blogPost.PostID });
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Deletes a blog post entity from the repository.
 /// </summary>
 /// <param name="blogPost">The blog post to be deleted.</param>
 public void DeleteBlogPost(BlogPost blogPost)
 {
     _dataContext.BlogPosts.DeleteObject(blogPost);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new BlogPost object.
 /// </summary>
 /// <param name="postID">Initial value of the PostID property.</param>
 /// <param name="author">Initial value of the Author property.</param>
 /// <param name="postedDate">Initial value of the PostedDate property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="body">Initial value of the Body property.</param>
 /// <param name="draft">Initial value of the Draft property.</param>
 public static BlogPost CreateBlogPost(global::System.Int32 postID, global::System.String author, global::System.DateTime postedDate, global::System.String title, global::System.String body, global::System.Boolean draft)
 {
     BlogPost blogPost = new BlogPost();
     blogPost.PostID = postID;
     blogPost.Author = author;
     blogPost.PostedDate = postedDate;
     blogPost.Title = title;
     blogPost.Body = body;
     blogPost.Draft = draft;
     return blogPost;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds a new blog post entity to the repository.
 /// </summary>
 /// <param name="blogPost">The blog post to be added.</param>
 public void AddBlogPost(BlogPost blogPost)
 {
     _dataContext.BlogPosts.AddObject(blogPost);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the BlogPosts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBlogPosts(BlogPost blogPost)
 {
     base.AddObject("BlogPosts", blogPost);
 }