/// <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
Ejemplo n.º 3
0
        public async Task <List <Blog_Posts> > GetBlogsSummary()
        {
            List <Blog_Posts> blog_postList = new List <Blog_Posts>();
            var datalist = await(from b in _context.Blogs
                                 join p in _context.Posts on b.BlogId equals p.BlogId
                                 select new { b.BlogId, p.PostUrl, b.Subject, p.Title, p.Content }
                                 ).ToListAsync();

            datalist.ForEach(bp =>
            {
                var newblogpost         = new Blog_Posts();
                newblogpost.BlogId      = bp.BlogId;
                newblogpost.PostUrl     = bp.PostUrl;
                newblogpost.BlogName    = bp.Subject;
                newblogpost.postName    = bp.Title;
                newblogpost.postContent = bp.Content;
                blog_postList.Add(newblogpost);
            }
                             );
            return(blog_postList);
        }
Ejemplo n.º 4
0
        ///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