public static bool FindAndDelete( ISession session, int accountid, Type type, int objectid, ManagedSecurityContext sec) { Discussion discussion = Find(session, accountid, type, objectid, sec); if (discussion == null) { return(false); } ManagedDiscussion m_instance = new ManagedDiscussion(session, discussion); m_instance.Delete(sec); return(true); }
public static bool FindAndDelete( ISession session, Type type, int objectid, ManagedSecurityContext sec) { DataObject dataobject = ManagedDataObject.FindObject(session, type); IList <Discussion> discussions = session.CreateCriteria(typeof(Discussion)) .Add(Expression.Eq("DataObject.Id", dataobject.Id)) .Add(Expression.Eq("ObjectId", objectid)) .Add(Expression.Eq("Personal", true)) .List <Discussion>(); foreach (Discussion discussion in discussions) { ManagedDiscussion m_instance = new ManagedDiscussion(session, discussion); m_instance.Delete(sec); } return(discussions.Count > 0); }