public bool IsPostCommentExist(Domain.Socioboard.Domain.FbPageComment _FbPageComment) { //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()) { try { //Proceed action to, get all wall post of Facebook User. List <Domain.Socioboard.Domain.FbPageComment> alst = session.CreateQuery("from FbPageComment where UserId = :userid and PostId = :postid and FromId = :fromid and CommentId = :commentid") .SetParameter("postid", _FbPageComment.PostId) .SetParameter("userid", _FbPageComment.UserId) .SetParameter("fromid", _FbPageComment.FromId) .SetParameter("commentid", _FbPageComment.CommentId) .List <Domain.Socioboard.Domain.FbPageComment>() .ToList <Domain.Socioboard.Domain.FbPageComment>(); if (alst.Count > 0) { return(true); } else { return(false); } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(true); } } //End Transaction } //End session }
public int UpdateFbPageCommentStatus(Domain.Socioboard.Domain.FbPageComment _FbPageComment) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { int i = session.CreateQuery("Update FbPageComment set Likes =:Likes,UserLikes =:UserLikes where PostId =:PostId and CommentId =:CommentId") .SetParameter("Likes", _FbPageComment.Likes) .SetParameter("UserLikes", _FbPageComment.UserLikes) .SetParameter("CommentId", _FbPageComment.CommentId) .SetParameter("PostId", _FbPageComment.PostId) .ExecuteUpdate(); transaction.Commit(); return(i); } catch (Exception ex) { return(0); } } } return(0); }
/// <addFbPageComment> /// Add new FbPageComment /// </summary> /// <param name="fbmsg">Set Values in a FbPageComment Class Property and Pass the same Object of FbPageComment Class.(Domain.FbPageComment)</param> public void addFbPageComment(Domain.Socioboard.Domain.FbPageComment _FbPageComment) { //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 save data. session.Save(_FbPageComment); transaction.Commit(); } //End Transaction } //End session }