// toggles User.IsStaff on/off
 public void toggleStaff(User u)
 {
     if (!u.IsStaff)
     {
         u.IsStaff = true;
     }
     else
     {
         u.IsStaff = false;
     }
     wce.SaveChanges();
 }
 // if user has role, removes and returns true, otherwise false
 public Boolean removeGroup(User u, Group g)
 {
     if (!u.Groups.IsLoaded)
     {
         u.Groups.Load();
     }
     if (u.Groups.Contains(g))
     {
         u.Groups.Remove(g);
         wce.SaveChanges();
         return true;
     }
     else
     {
         return false;
     }
 }
        //
        // Summary:
        //     Adds a new membership user to the data source.
        //
        // Parameters:
        //   username:
        //     The user name for the new user.
        //
        //   password:
        //     The password for the new user.
        //
        //   email:
        //     The e-mail address for the new user.
        //
        //   passwordQuestion:
        //     The password question for the new user.
        //
        //   passwordAnswer:
        //     The password answer for the new user
        //
        //   isApproved:
        //     Whether or not the new user is approved to be validated.
        //
        //   providerUserKey:
        //     The unique identifier from the membership data source for the user.
        //
        //   status:
        //     A System.Web.Security.MembershipCreateStatus enumeration value indicating
        //     whether the user was created successfully.
        //
        // Returns:
        //     A System.Web.Security.MembershipUser object populated with the information
        //     for the newly created user.
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            using (WindchimeEntities wce = new WindchimeEntities())
            {
                Regex re = new Regex(this.PasswordStrengthRegularExpression);
                User u = new User();
                Group g = new Group();
                u.FirstName = "";
                u.LastName = "";
                u.Username = username;
                u.Password = SecurityManager.HashPasswordForStoringInDatabase(password);
                u.IsStaff = false;
                u.Email = email;
                g.Name = username;
                g.IsSpecial = false;

                if (username.Length < 6)
                {
                    status = MembershipCreateStatus.UserRejected;
                }
                else if ((from User k in wce.CreatorSet.OfType<User>()
                     where k.Username == username
                     select k).Count<User>() > 0)
                {
                   status = MembershipCreateStatus.DuplicateUserName;
                }
                else if (!re.IsMatch(password))
                {
                    status = MembershipCreateStatus.InvalidPassword;
                }
                else if (!isEmail(email))
                {
                    status = MembershipCreateStatus.InvalidEmail;
                }
                else if ((from User k in wce.CreatorSet.OfType<User>()
                          where k.Email == email
                          select k).Count<User>() > 0)
                {
                    status = MembershipCreateStatus.DuplicateEmail;
                }
                else
                {
                    status = MembershipCreateStatus.Success;
                    wce.AddToCreatorSet(u);
                    wce.AddToGroups(g);
                    g.Users.Add(u);
                    wce.SaveChanges();
                    // log in the user
                    WindchimeSession.Current.User = u;
                }
            }

            return null;
        }