- Microsoft.EntityFrameworkCore 9.0.3
- Microsoft.EntityFrameworkCore.Design 9.0.3
- Microsoft.EntityFrameworkCore.SqlServer 9.0.3 (for docker deployment)
- Microsoft.EntityFrameworkCore.Sqlite 9.0.3 (for local deployment)
- Swashbuckle.AspNetCore 8.1.0
- Microsoft.AspNetCore.Identity.EntityFrameworkCore 8.0.2
- xunit 2.5.3
- xunit.runner.visualstudio 2.5.3
- Microsoft.NET.Test.Sdk 17.8.0
- Microsoft.EntityFrameworkCore.InMemory 9.0.3
- coverlet.collector 6.0.0
Under solution directory (where you see the UniversityDirectory.sln), run the following commands:
docker-compose up -d mssqlCheck the log to ensure the database is initialised before running the next command.
dotnet ef migrations add Initial --project UniversityDirectory dotnet ef database update --project UniversityDirectorydocker-compose up -d univerisitydirectory --build
- Edit the
connectionStringin Program.cs:var connectionString = builder.Configuration.GetConnectionString("Sqlite");and change the
options.UseSqlServertooptions.UseSqlite.
- Run the following commands:
dotnet builddotnet ef migrations add Initial --project UniversityDirectory dotnet ef database update --project UniversityDirectorydotnet run --project UniversityDirectoryOr simply run the program from Visual Studio.
In Visual Studio, run the UniversityTests.cs under UniversityUnitTest to check the test results.
- Navigate to
http://localhost:[port]/swagger/index.html, where [port] can be found in the terminal output (port 5000 for docker).- Register an account under
/register.- Login using the registered account to obtain the
accessTokenfrom the response body.- Look for the green
Authorizebutton at the top right corner, paste theaccessTokenwith format:Bearer [acccessToken]- Test the various university api endpoints.
Retrieve a list of all universities. Bookmarked universities will appear in the beginning and deleted universities will not be shown by default.
Does not require accessToken.
Supports parameter filtering:
- ?name=[Name]: return university with the given name.
- ?country=[Country]: return universities of the given country.
- ?isBookmark=[true/false]: return bookmarked/not bookmarked universities.
- ?isActive=[true/false]: return active/non-active universities.
- ?isDeleted=[true/false]: return deleted/not deleted universities.
- ?pageNumber=[number]&pageSize=[number]: for pagination, default pageNumber=1&pageSize=10
Add a university. The UTC time of creation will be recorded.
Require accessToken
Request body:
- name (required): Name of the university.
- country (required): Country of the university.
- webpage: Webpage of the university.
- isBookmark: default false.
- isActive: default true.
Retrive the university of the given id.
If the id is not found, returns 404.
Will return deleted university.
Does not require accessToken.
Updates the university of the given id. The UTC time of update will be recorded in lastModified.
If the id is not found, returns 404.
If the id is deleted, returns 400.
Else, return the university updated.
Requires accessToken.
Soft delete the university of the given id by setting the
deletedAtproperty to the UTC time of delete action.If the id is not found, returns 404.
If the id is already deleted, returns 204.
Else, return the university deleted.
Requires accessToken.
Bookmark the university of the given id. This action is similar to the
PUTaction but only changesisBookmarkandlastModified.If the id is not found, returns 404.
If the id is deleted, returns 400.
Requires accessToken.