示例#1
0
        public static void UserUpdate()
        {
            UserArgs args = PSCDialog.DataShare as PSCPortal.Security.UserArgs;
            CustomMembershipProvider customMembership = new CustomMembershipProvider();
            bool validate = customMembership.ValidateEmail(args.User);

            if (validate == false)
            {
                return;
            }
            args.User.Update();
            string               groupAdmin           = System.Configuration.ConfigurationManager.AppSettings["GroupAdmin"];
            RoleCollection       rolesOfUser          = RoleCollection.GetRoleCollection(args.User.Name);
            Role                 roleAdmin            = rolesOfUser.SingleOrDefault(r => r.Name == groupAdmin);
            UserInRoleCollection userInRoleCollection = new UserInRoleCollection();
            UserInRole           userInRole           = null;

            if (args.IsAdministrator)
            {
                // if user exist role administrator
                if (roleAdmin == null)
                {
                    userInRole = new UserInRole();
                    Role radmin = RoleCollection.GetRoleCollection().Single(r => r.Name == groupAdmin);
                    userInRole.RoleId = radmin.Id;
                    userInRole.UserId = args.User.Id;
                    userInRoleCollection.AddDB(userInRole);
                }
            }
            else
            {
                if (roleAdmin != null)
                {
                    userInRole        = new UserInRole();
                    userInRole.RoleId = roleAdmin.Id;
                    userInRole.UserId = args.User.Id;
                    userInRoleCollection.Add(userInRole);
                    userInRoleCollection.RemoveDB(userInRole);
                }
            }
            DataStatic["DisplayUserList"] = null;
            DataStatic["UserList"]        = null;
        }