Exemple #1
0
        public void AddRolesToUser(string[] roleNames, string userName)
        {
            var userService = new UserService();

            var user = userService.GetUser(userName);
            if (user != null)
            {
                var roles = user.MemberShip.Roles;
                foreach (var item in roleNames)
                {
                    if (!roles.Select(x => x.RoleName).Contains(item))
                    {
                        var role = GetRole(item);
                        if (role != null)
                            user.MemberShip.Roles.Add(role);
                    }
                }
                userService.UpdateMemberShip(user.MemberShip);
            }
        }
 public override bool DeleteUser(string username, bool deleteAllRelatedData)
 {
     var service = new UserService();
     var user = service.GetUser(username);
     if (user == null)
         return false;
     if (deleteAllRelatedData)
         service.DeleteAccount(username);
     service.DeleteUser(user);
     return true;
 }