/// <summary> /// Deletes the post. /// </summary> /// <param name="post">The post.</param> /// <returns></returns> public int DeletePost(EBlogPost post) { return ExecuteNonQuery( @"Delete TBlogPost WHERE PostID = @PostID;", CreateParameter("@PostID", post.PostID)); }
/// <summary> /// Inserts the post. /// </summary> /// <param name="post">The post.</param> /// <returns></returns> public int InsertPost(EBlogPost post) { // return ExecuteNonQuery( // @"INSERT INTO TBlogPost( //BlogID, Title, [Content], Summary, PublishDate, LastModifiedDate, Author, IsPublished, Visible, ReadCount) //VALUES ( //@BlogID, @Title, @Content, @Summary, @PublishDate, @LastModifiedDate, @Author, @IsPublished, @Visible, @ReadCount)", // CreateParameter("@BlogID", post.BlogID), // CreateParameter("@Title", post.Title), // CreateParameter("@Content", post.Content), // CreateParameter("@Summary", post.Summary), // CreateParameter("@PublishDate", post.PublishDate), // CreateParameter("@LastModifiedDate", post.LastModifiedDate), // CreateParameter("@Author", post.Author), // CreateParameter("@IsPublished", post.IsPublished), // CreateParameter("@Visible", post.Visible), // CreateParameter("@ReadCount", post.ReadCount) // ); return ExecuteInsertQueryReturnID( "TBlogPost", new Dictionary<string, object>() { {"BlogID", post.BlogID}, {"Title", post.Title}, {"Content", post.Content}, {"Summary", post.Summary}, {"PublishDate", post.PublishDate}, {"LastModifiedDate", post.LastModifiedDate}, {"Author", post.Author}, {"IsPublished", post.IsPublished}, {"Visible", post.Visible}, {"ReadCount", post.ReadCount}, }); }
/// <summary> /// Updates the post. /// </summary> /// <param name="post">The post.</param> /// <returns></returns> public int UpdatePost(EBlogPost post) { return ExecuteNonQuery( @"UPDATE TBlogPost SET BlogID = @BlogID, Title = @Title, [Content] = @Content, Summary = @Summary, PublishDate = @PublishDate, LastModifiedDate = @LastModifiedDate, Author = @Author, IsPublished = @IsPublished, Visible = @Visible, ReadCount = @ReadCount WHERE PostID = @PostID;", CreateParameter("@BlogID", post.BlogID), CreateParameter("@Title", post.Title), CreateParameter("@Content", post.Content), CreateParameter("@Summary", post.Summary), CreateParameter("@PublishDate", post.PublishDate), CreateParameter("@LastModifiedDate", post.LastModifiedDate), CreateParameter("@Author", post.Author), CreateParameter("@IsPublished", post.IsPublished), CreateParameter("@Visible", post.Visible), CreateParameter("@ReadCount", post.ReadCount), CreateParameter("@PostID", post.PostID)); }
/// <summary> /// Changes the specified post. /// </summary> /// <param name="post">The post.</param> /// <returns></returns> protected BBlogPost Change(EBlogPost post) { return new BBlogPost() { PostID = post.PostID, Author = post.Author, BlogID = post.BlogID, Content = post.Content, IsPublished = post.IsPublished, LastModifiedDate = post.LastModifiedDate, PublishDate = post.PublishDate, ReadCount = post.ReadCount, Summary = post.Summary, Title = post.Title, Visible = post.Visible }; }