Exemplo n.º 1
0
        /// <summary>Creates a new, empty ForumRoleForumActionRightEntity object.</summary>
        /// <returns>A new, empty ForumRoleForumActionRightEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new ForumRoleForumActionRightEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewForumRoleForumActionRight
            // __LLBLGENPRO_USER_CODE_REGION_END
            return toReturn;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the given set of actionrights as the set of forum action rights for the given forum / role combination.
        /// It first removes all current action rights for that combination.
        /// </summary>
        /// <param name="actionRightIDs">List of actionrights to set of this role</param>
        /// <param name="roleID">Role to use</param>
        /// <param name="forumID">Forum to use</param>
        /// <returns>true if succeeded, false otherwise</returns>
        public static bool SaveForumActionRightsForForumRole(List<int> actionRightIDs, int roleID, int forumID)
        {
            ForumRoleForumActionRightCollection forumRightsPerRole = new ForumRoleForumActionRightCollection();
            Transaction trans = new Transaction(IsolationLevel.ReadCommitted, "SaveForumActionRights");

            // add this collection to the transaction so all actions executed through this collection will be inside the transaction
            trans.Add(forumRightsPerRole);
            try
            {
                // first remove the existing rows for the role
                forumRightsPerRole.DeleteMulti((ForumRoleForumActionRightFields.RoleID == roleID).And(ForumRoleForumActionRightFields.ForumID == forumID));

                // THEN add new ones
                foreach(int actionRightID in actionRightIDs)
                {
                    ForumRoleForumActionRightEntity newForumRightPerRole = new ForumRoleForumActionRightEntity();
                    newForumRightPerRole.ActionRightID = actionRightID;
                    newForumRightPerRole.ForumID = forumID;
                    newForumRightPerRole.RoleID = roleID;
                    forumRightsPerRole.Add(newForumRightPerRole);
                }

                // save the new entities
                forumRightsPerRole.SaveMulti();

                // all done, commit transaction
                trans.Commit();
                return true;
            }
            catch
            {
                // failed, rollback transaction
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }
        }