/// <summary>
 /// Adds the specified role right assignments,adding the RoleRightAssignment objects into RoleRightAssignmentCollection.
 /// </summary>
 /// <param name="roleRightAssignments">The role right assignments.</param>
 public void Add(RoleRightAssignmentCollection roleRightAssignments)
 {
     foreach (RoleRightAssignment rra in roleRightAssignments)
     {
         this.Add(rra);
     }
 }
        /// <summary>
        /// Saves the associate rights to role.
        /// </summary>
        /// <param name="role">The role.</param>
        /// <param name="rightIds">The right ids.</param>
        public void SaveAssociateRightsToRole([DataBind("role")]Role role, [DataBind("right.IsGranted")]int[] rightIds)
        {
            #region Logging
            if (log.IsDebugEnabled) log.Debug(Messages.MethodEnter);
            #endregion

            IRoleRightAssignmentSvc roleRightAssignmentSvc = GatekeeperFactory.RoleRightAssignmentSvc;

            //Gets role of a specified roleId.
            role = GatekeeperFactory.RoleSvc.Get(role.Id);

            //Gets application of a specified role.
            Application application = GatekeeperFactory.ApplicationSvc.Get(role.Application.Id);

            //Gets RoleRightAssignmentCollection of a specified role.
            RoleRightAssignmentCollection existingRoleRightAssignments = roleRightAssignmentSvc.Get(role);

            RoleRightAssignmentCollection selectedRoleRightAssignments = new RoleRightAssignmentCollection();

            foreach (int rightId in rightIds)
            {
                RoleRightAssignment rra = new RoleRightAssignment()
                {
                    Right = new Right() { Id = rightId },
                    Role = role,
                    Application = application,
                    SecurableObjectType = role.SecurableObjectType
                };

                selectedRoleRightAssignments.Add(rra);
            }

            RoleRightAssignmentCollection newRoleRightAssignments = new RoleRightAssignmentCollection();
            RoleRightAssignmentCollection deletedRoleRightAssignments = new RoleRightAssignmentCollection();

            foreach(RoleRightAssignment existingRra in existingRoleRightAssignments)
            {
                if (!selectedRoleRightAssignments.Contains(existingRra))
                    deletedRoleRightAssignments.Add(existingRra);
            }

            foreach (RoleRightAssignment selectedRra in selectedRoleRightAssignments)
            {
                if (!existingRoleRightAssignments.Contains(selectedRra))
                    newRoleRightAssignments.Add(selectedRra);
            }

            //Adds newRoleRightAssignments into the system.
            roleRightAssignmentSvc.Add(newRoleRightAssignments);

            //Deletes roleRightAssignment from the system.
            roleRightAssignmentSvc.Delete(deletedRoleRightAssignments);

            Hashtable args = new Hashtable();
            args["roleId"] = role.Id;

            this.RedirectToAction("displayRightsByRole", args);

            #region Logging
            if (log.IsDebugEnabled) log.Debug(Messages.MethodLeave);
            #endregion
        }
 /// <summary>
 /// Deletes the specified role right assignments,deleting the RoleRightAssignment objects from the RoleRightAssignmentCollection.
 /// </summary>
 /// <param name="roleRightAssignments">The role right assignments.</param>
 public void Delete(RoleRightAssignmentCollection roleRightAssignments)
 {
     foreach(RoleRightAssignment rra in roleRightAssignments)
         this.Delete(rra);
 }
 void PopulateDetails(RoleRightAssignmentCollection roleRightAssignments)
 {
     foreach(RoleRightAssignment rra in roleRightAssignments)
         this.PopulateDetails(rra);
 }