public static DAL.User UpdateUser(DAL.User user)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (BLL.UserManager um = new BLL.UserManager())
                    {
                        DAL.User oldUser = um.GetUserByID(user.UserID);
                        if (oldUser != null)
                        {
                            if (oldUser.UserName != user.UserName)
                                throw new Exceptions.UserException("Changing user name is not allowed.");
                            string[] roles = user.Role.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            if (roles.Length > 0)
                                AddUserToRoles(user.UserName, roles);
                            MembershipUser mUser = WebSecurity.Membership.GetUser(user.UserName);
                            user.MembershipProviderKey = (Guid)mUser.ProviderUserKey;
                            user = um.UpdateUser(user);
                        }
                        else
                        {
                            throw new Exceptions.UserException("No user found to update.");
                        }
                    }
                    ts.Complete();
                    return user;
                }

            }
            catch (Exceptions.UserException userex)
            {
                throw userex;
            }
            catch (Exception)
            {
                throw new Exceptions.UserException("Updating user failed.");
            }
        }
 public static DAL.User GetUserById(int userId)
 {
     using (BLL.UserManager um = new BLL.UserManager())
     {
         return um.GetUserByID(userId);
     }
 }