Yes, that was the problem, I had to replace the session manager by the new one:
- Add the Castle libraries to the references
Replace the following code:
This
public class ForumModule : ModuleBase
To
public class ForumModule : ModuleBase, INHibernateModule
AND
this
this._currentAction = ForumModuleAction.ForumList;
//
// Register all the forum classes
//
_categorySortBy = CategorySortBy.None;
_categorySortDirection = SortDirection.ASC;
_forumSortBy = ForumSortBy.None;
_forumSortDirection = SortDirection.ASC;
_forumPostSortBy = ForumPostSortBy.DateCreated;
_forumPostSortDirection = SortDirection.ASC;
SessionFactory sf = SessionFactory.GetInstance();
sf.RegisterPersistentClass(typeof(ForumForum));
sf.RegisterPersistentClass(typeof(ForumCategory));
sf.RegisterPersistentClass(typeof(ForumPost));
sf.RegisterPersistentClass(typeof(ForumEmotion));
sf.RegisterPersistentClass(typeof(ForumTag));
sf.RegisterPersistentClass(typeof(ForumUser));
sf.RegisterPersistentClass(typeof(ForumFile));
base.SessionFactoryRebuilt = sf.Rebuild();
this._forumthemepath = UrlHelper.GetApplicationPath() + "Modules/Forum/Images/Standard/";
to
_sessionManager = sessionManager;
this._currentAction = ForumModuleAction.ForumList;
//
// Register all the forum classes
//
_categorySortBy = CategorySortBy.None;
_categorySortDirection = SortDirection.ASC;
_forumSortBy = ForumSortBy.None;
_forumSortDirection = SortDirection.ASC;
_forumPostSortBy = ForumPostSortBy.DateCreated;
_forumPostSortDirection = SortDirection.ASC;
this._forumthemepath = UrlHelper.GetApplicationPath() + "Modules/Forum/Images/Standard/";
And then replace for each method
this
public IList GetForumsByCategoryId(int categoryid)
{
try
{
string hql = "from ForumForum f where f.CategoryId = :categoryId " + this.GetCategoryOrderByClause("f"
;
IQuery q = base.NHSession.CreateQuery(hql);
q.SetInt32("categoryId", categoryid);
return q.List();
}
catch (Exception ex)
{
throw new Exception("Unable to get forum by category", ex);
}
}
to
public IList GetForumsByCategoryId(int categoryid)
{
ISession session = this._sessionManager.OpenSession();
try
{
string hql = "from ForumForum f where f.CategoryId = :categoryId " + this.GetCategoryOrderByClause("f"
;
IQuery q = session.CreateQuery(hql);
q.SetInt32("categoryId", categoryid);
return q.List();
}
catch (Exception ex)
{
throw new Exception("Unable to get forum by category", ex);
}
}
for the update or delete methods:
from this
public void SaveForum(ForumForum forum)
{
ITransaction tx = base.NHSession.BeginTransaction();
try
{
base.NHSession.SaveOrUpdate(forum);
tx.Commit();
}
catch (Exception ex)
{
tx.Rollback();
throw new Exception("Unable to save Forum ", ex);
}
}
to
[Transaction(TransactionMode.RequiresNew)]
public virtual void SaveForum(ForumForum forum)
{
ISession session = this._sessionManager.OpenSession();
try
{
session.SaveOrUpdate(forum);
}
catch (Exception ex)
{
throw new Exception("Unable to save Forum ", ex);
}
}
That's it!
I will post the complete forum as soon as I get it finished.