I have been trying to create a "login" for the students in the company I work with, which is not really a log in but more of a system so that students access their own folder (which has their name on them) in Dropbox and not access other students folder and possibly delete them the contents in them.
The way the login works, is that the student types their first and last name, once they do, the systems checks if the name exists. The systems checks path /students/summit/firstname.lastname.
The reason why we have a dot in the middle is that we can feed a bunch of names separated by a comma to a little system that we have, that creates a bunch of student's folders very quickly.
I am using ASP.NET Core MVC and so far most of my system is working, I just need to help with the last part of the program.
The last part is to manage if a student mistypes a name or if a folder with the student name is not created. If the name is not found, then it takes the first letter of the first name and the first letter of the last name and lists all the students that match that condition.
If the students find their name on the list then they select it and the login gets repopulated with the first name and last name selected, if not then we create a folder with that name (manually)-- later I want to add a part that allows to create that folder on the spot but I do not want to fill the Dropbox with a bunch of duplicates or name typos.
`private async Task<List<string>> SearchStudentNames(DropboxClient dropbox, string firstName, string lastName)
{
var similarNames = new List<string>();
try
{
// Construct the query
var query = $"{firstName.ToLower()[0]}*.{lastName.ToLower()[0]}*";
// Perform the search
var searchResult = await dropbox.Files.SearchV2Async(query);
// Extract folder names from the search result
foreach (var match in searchResult.Matches)
{
// Check if the matched item represents a folder
if (match.Metadata.IsFolder)
{
// Extract the folder name and add it to the list
similarNames.Add(match.Metadata.AsFolder.Name);
}
}
}
catch (Exception ex)
{
// Handle exception, e.g., Dropbox API error
// Log the exception or return an empty list in case of failure
}
return similarNames;
}`
This is the code that searches for student names, but since I am "SearchSyncV2," then "match.Metadata.IsFolder" throws me an error and "similarNames.Add(match.Metadata.AsFolder.Name)" also throws me an error.
similarNames.Add(match.Metadata.AsFolder.Name) errror
Please let me know if you need more information. Thank you everyone for all your help.
I tried looking at the Dropbox V2 documentation, but I believe is written in a different code. I also tried researching on Google to see if there was somebody that had a similar issue.
I usually run my code through ChatGPT so that it gives more "clean" code or better ways to write something I was trying to accomplish, but even ChatGPT does not know how Dropbox Api V2 works.