/// <summary> /// Gives the user a specific role when requeated. /// It will check the rolename against the database then attempt /// to give the user this role. /// </summary> /// <param name="userID">The ID of the user to give the role</param> /// <param name="role">Name of the role to be added</param> internal static void GiveRole(int userID, string role) { //Gets the role from the database. var dbRole = DatabaseConnector.GetRoleID(role); //IF the role is not found it retuns -1. if (dbRole == -1) { throw new KeyNotFoundException("Unable to find the key matching this role"); } // Gets the database to add the user role. DatabaseConnector.AddUserRole(new UserRoles() { UserID = userID, RoleID = dbRole }); }