Exemple #1
0
        public ActionResult New(PostViewModel view)
        {
            if (ModelState.IsValid)
            {
                Post post = new Post
                {
                    Title = view.Title,
                    Message = view.Message,
                    PostedBy = User.ID
                };

                _postsRepository.Create(post);
                return RedirectToAction("Index");
            }

            return View(view);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Posts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPosts(Post post)
 {
     base.AddObject("Posts", post);
 }
 /// <summary>
 /// Create a new Post object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="message">Initial value of the Message property.</param>
 /// <param name="postedBy">Initial value of the PostedBy property.</param>
 public static Post CreatePost(global::System.Int32 id, global::System.String title, global::System.String message, global::System.Int32 postedBy)
 {
     Post post = new Post();
     post.ID = id;
     post.Title = title;
     post.Message = message;
     post.PostedBy = postedBy;
     return post;
 }