Пример #1
0
    /// <summary>
    /// Function used modify registered user into the database.
    /// </summary>
    /// <param name="username">
    /// Used to identified which user to updated.
    /// </param>
    /// <param name="password">
    /// User provided updated password
    /// </param>
    /// <param name="firstName">
    /// User provided updated first name
    /// </param>
    /// <param name="lastName">
    /// User provided updated last name
    /// </param>
    /// <param name="interests">
    /// User provide updated list of topics
    /// </param>
    /// <returns>
    /// Boolean value to determine if modification was sucessful.
    /// </returns>
    public Boolean modifyUser(string username, string firstName, string lastName, string oldpassword, string password, string[] interests)
    {
        try
        {
            userdataDBTableAdapters.DataTableTableAdapter  adapt  = new userdataDBTableAdapters.DataTableTableAdapter();
            userdataDBTableAdapters.DataTable2TableAdapter adapt2 = new userdataDBTableAdapters.DataTable2TableAdapter();
            adapt.FillLogin(data.DataTable, oldpassword, username);
            if (data.DataTable.Count() == 1)
            {
                //run update for first name, last name, password
                adapt2.modifyUser(username, firstName, lastName, password);
                //delte all interests
                adapt2.deleteUserInterest(username);
                //insert interests
                foreach (string s in interests)
                {
                    adapt2.insertUserInterest(username, s);
                }
                return(true);
            }

            return(false);
        }
        catch
        {
            return(false);
        }
    }
Пример #2
0
 /// <summary>
 /// Function used check the user provided credentials in the database
 /// </summary>
 /// <param name="username">
 /// User provided username
 /// </param>
 /// <param name="password">
 /// User provided password
 /// </param>
 /// <returns>
 /// Boolean value for the provided credentials.
 /// </returns>
 public Boolean checklogin(string username, string password)
 {
     userdataDBTableAdapters.DataTableTableAdapter adapt = new userdataDBTableAdapters.DataTableTableAdapter();
     adapt.FillLogin(data.DataTable, password, username);
     if (data.DataTable.Count() == 1)
     {
         return(true);
     }
     return(false);
 }