You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Design an API that can be used to query the dataset
Consumers of the API must be able to search by film title / name
Consumers of the API must be able to limit the search results returned
Consumers of the API must be able to perform paged searches of results
Consumers of the API should be able to filter movies by genre
Additional optional requirements
Consumers of the API may wish to search by actor
Consumers of the API may wish to search by more than one actor using and/or combinations
Testing
Before attempting to run the application locally, the database must be configured correctly:
If using LocalDB:
Using the MSSQLLocalDb instance, no changes to the connection string are required
If using a different named instance, the appsettings.development.json file will need to be updated with the name of the named instance
If using SQL Server:
Note the name of the server and connection requirements - i.e. if not using the trusted connection option, then a username and password must be supplied
Update the appsettings.development.json file, replacing (localDb)\\MSSQLLocalDb with the appropriate connection information for the server being connected to
If not using trusted connection, remove the Trusted_Connection=true, replacing it with User ID=[username];Password=[password], replacing the username and password with the appropriate values
Again, prior to attempting to run the application, the database must be created / initialised, or when connecting to it, the console will output SQL errors / exceptions!
If using Visual Studio: open the "Package Manager Console" from the View->Other Windows menu option
If using VSCode, open a Terminal session
Before starting, you will need to make sure the EF Core CLI tools are installed. To check if they are, run the command dotnet ef in the appropriate console window. If the tools are not installed, you will see an error message such as Could not execute because the specified command or file was not found. If this is the case, one further step is required before going any further:
From the console window, execute the command dotnet tool install --global dotnet-ef
When completed, re-try the dotnet ef command again. If you do not see an error, you should be able to continue
From the command window (Package Manager Console or Terminal session), ensure the current folder is the root of the project, e.g. [git clone root location]/movie-api
From the command-line, run the following: dotnet ef database update -c MovieContext -p ./MovieApiData/ -s ./movie-api/ - direction of slashes may be different, dependent upon OS, console used etc.
Now the database is configured and initialised, you can run the project
Using Visual Studio - use F5, Ctrl+F5, one of the "play" controls on the menu ribbon etc., that should auto-launch the API in a new browser window and navigate to the swagger page
Using VSCode - from a terminal, use this command: dotnet run --project ./movie-api/movie-api.csproj. The console output should show the localhost address to navigate to, ctrl+click on the link shown and it should open in a browser - most likely with an error. To fix this, append /swagger to the URL shown in the address bar and refresh
On first running the application, no data has been setup as yet, so queries should work, but won't yield any results. A sample dataset is provided and can be loaded into the database by using the /api/Import/LoadKaggleDataset endpoint. How quickly that will run depends an awful lot on your own configuration. Once completed, the API endpoints should now show data when querying them.
About
Proof of concept API for movies, consuming a CSV-based dataset