public static bool AddPost(Post newPost) { using (var db = new TwitterOnVaadinEntities()) { newPost.id = 1; db.Posts.AddObject(newPost); db.SaveChanges(); } return true; }
public bool AddPost(string Post, int Author, int User, string Date) { bool res = false; try { var post = new Post{ Post1 = Post, Author = Author, User = User, Date = Date, }; res = DataFunctions.AddPost(post); } catch (Exception ex) { //TODO: Logging return false; } return res; }
public static bool UpdatePost(Post newPost) { using (var db = new TwitterOnVaadinEntities()) { var post = db.Posts.FirstOrDefault(e => e.id == newPost.id); if (post != null) { post = newPost; } db.SaveChanges(); } return true; }
/// <summary> /// Create a new Post object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="post1">Initial value of the Post1 property.</param> /// <param name="date">Initial value of the Date property.</param> /// <param name="user">Initial value of the User property.</param> /// <param name="author">Initial value of the Author property.</param> public static Post CreatePost(global::System.Int32 id, global::System.String post1, global::System.String date, global::System.Int32 user, global::System.Int32 author) { Post post = new Post(); post.id = id; post.Post1 = post1; post.Date = date; post.User = user; post.Author = author; return post; }
/// <summary> /// Deprecated Method for adding a new object to the Posts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPosts(Post post) { base.AddObject("Posts", post); }