/// <Update> /// Update/Change value of blog post /// </summary> /// <param name="blog_Posts">Set Values in a blog posts Class Property and Pass the same Object of blog posts Class in paremeter.(Domain.Blog_Posts)</param> /// <returns></returns> public int Update(Blog_Posts blog_Posts) { int update = 0; try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action, to update Data session.Update(blog_Posts.Id, blog_Posts); transaction.Commit(); update = 1; }//End Trsaction }//End session } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return update; }
/// <GetAllBlogPosts> /// Get all BlogPosts /// </summary> /// <param name="blog_Posts"></param> /// <returns>Icollection of Blog post data objects </returns> public ICollection<Domain.Socioboard.Domain.Blog_Posts> GetAllBlogPosts(Blog_Posts blog_Posts) { ICollection<Blog_Posts> iCol = null; try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //Proceed action, to to get all blog posts iCol = session.CreateCriteria(typeof(Blog_Posts)).List<Blog_Posts>(); }//End session } catch (Exception ex) { Console.WriteLine("Error : "+ex.StackTrace); } return iCol; } // End Method
///NOT USED NOW. /// <summary> /// Get all Blog_Comments from Database by Id. /// </summary> /// <param name="objBlog_Posts">The object of the Blog_Comments class(Domain.Blog_Comments)</param> /// <returns>Return all Comment By BlogId in the form of List type.</returns> public ICollection<Blog_Comments> GetAllCommentByBlogIda(Blog_Posts objBlog_Posts) { ICollection<Blog_Comments> iCol = null; // ICollection<Blog_Comments> iColById = null; try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //Proceed action, to get all data iCol = session.CreateCriteria(typeof(Blog_Comments)).List<Blog_Comments>() .Where< Blog_Comments > (x => x.CommentPostId == objBlog_Posts.Id).ToList<Blog_Comments>(); // iColById = iCol.Where<Blog_Comments>(x => x.CommentPostId == objBlog_Posts.Id).ToList<Blog_Comments>(); }//End session } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return iCol; }//End Method