/// <summary>v /// Creates a new user with the specified details /// This is used when an admin is making a single user /// for their organisation who may have been missed off the /// long user list. /// </summary> /// <param name="uname">Username of new user</param> /// <param name="organisationID">Id of the organisation</param> /// <param name="password">The new users password</param> /// <param name="firstname">the First name of the new user</param> /// <param name="lastname">Last name of the new user</param> /// <returns>The user that has been added</returns> internal static Users CreateNewUser(string uname, int organisationID, string password, string firstname, string lastname) { Users usr = new Users() { Username = uname, //Makes sure to hash the password before it is put in the database Password = Hasher.Hash(password), First_Name = firstname, Last_Name = lastname, OrganisationID = organisationID, //Indicates that the user has not logged in yet. Last_Logged_In = DateTime.MinValue }; try { //Creates the new user using the database methods and setup the new userID usr.UserID = DatabaseConnector.AddUser(usr); return(usr); } // An error was returned when adding to the database catch (Exception ex) { return(new Users() { Username = USER_ERROR }); } }
/// <summary> /// Creates a new user with the specified details /// This is used when an admin is making a single user /// for their organisation who may have been missed off the /// long user list. /// </summary> /// <param name="uid">User ID of the Admin</param> /// <param name="uname">Username of new user</param> /// <param name="password">The new users password</param> /// <param name="firstname">the First name of the new user</param> /// <param name="lastname">Last name of the new user</param> /// <returns>The user that has been added</returns> internal static Users CreateNewUser(int uid, string uname, string password, string firstname, string lastname) { Users usr = new Users() { Username = uname, //Makes sure to hash the password before it is put in the database Password = Hasher.Hash(password), First_Name = firstname, Last_Name = lastname, // Gets the organisation of the user calling this method OrganisationID = GetUser(uid).OrganisationID }; try { //Creates the new user using the database methods and setup the new userID usr.UserID = DatabaseConnector.AddUser(usr); return(usr); } // An error was returned when adding to the database catch (Exception ex) { return(new Users() { Username = USER_ERROR }); } }