/// <summary>
        /// Saves a single User. Do not use this Method in combination with GetUsers/SetUsers!
        /// </summary>
        /// <param name="account">Users Account. If it does not exists a new User is created</param>
        /// <param name="password">Users password</param>
        /// <param name="firstName">Users First Name</param>
        /// <param name="surName">Users Sur Name</param>
        /// <param name="roles">ArrayList of Roles</param>
        public static void SaveUser(string account, string password, string firstName, string surName, ArrayList roles)
        {
            Users u = GetUsers();

            Users.UserRow user = u.User.FindBylogin(account.ToLower());
            if (user == null)
            {
                user = u.User.AddUserRow(account, password, firstName, surName);
            }
            else
            {
                user.password  = password;
                user.firstName = firstName;
                user.surName   = surName;
            }

            // Delete old Roles
            foreach (Users.UserRoleRow r in user.GetUserRoleRows())
            {
                r.Delete();
            }

            // Add new Roles
            foreach (string newRole in roles)
            {
                u.UserRole.AddUserRoleRow(u.Role.FindByname(newRole), user);
            }


            SetUsers(u);
        }
        /// <summary>
        /// Performs the Login.
        /// </summary>
        /// <param name="account">Users account</param>
        /// <param name="password">Users password</param>
        /// <returns>true if the credentials are valid</returns>
        public static bool Login(string account, string password)
        {
            Users u = GetUsers();

            Users.UserRow user = u.User.FindBylogin(account.ToLower());
            if (user == null)
            {
                return(false);
            }
            if (user.password != password)
            {
                return(false);
            }

            FormsAuthentication.SetAuthCookie(account, false);
            return(true);
        }
        /// <summary>
        /// Deletes a single user. Do not use this Method in combination with GetUsers/SetUsers!
        /// </summary>
        /// <param name="account"></param>
        public static void DeleteUser(string account)
        {
            Users u = GetUsers();

            Users.UserRow user = u.User.FindBylogin(account.ToLower());
            if (user == null)
            {
                throw new Exception("User not found");
            }
            string a = account.ToLower();

            if (account.ToLower() == API.Config.AdminRole.ToLower())
            {
                throw new Exception("Deleteing Admin Role is not allowed!");
            }
            user.Delete();
            SetUsers(u);
        }
        /// <summary>
        /// Returns the current Users Roles.
        /// </summary>
        /// <param name="account">Users account</param>
        /// <returns>string array of the users roles. Returns a empty array if the user is not found</returns>
        public static string[] GetRoles(string account)
        {
            Users u = GetUsers();

            Users.UserRow user = u.User.FindBylogin(account.ToLower());
            if (user == null)
            {
                return(new string[0]);
            }

            Users.UserRoleRow[] roles  = user.GetUserRoleRows();
            string[]            result = new string[roles.Length];
            for (int i = 0; i < roles.Length; i++)
            {
                result[i] = roles[i].RoleRow.name;
            }

            return(result);
        }