*Note: Run project in Vscode instead of Visual Studio.
To start up the server:
dotnet watch run
The launchUrl is set to [localhost/api/users/seed](http://localhost/api/users/seed)
: for testing purpose, I have setup a few seed data ( can be found in Controllers/UsersController, Seed
). I have tried to seed data with DbContext using HasData() but through some searching, this only seems to work with real db and not InMemory ones.
The seed url then right away redirect to /api/users
This route need proper authorization to get access to. You should be receiving 401
after being redirected here without login
-
Login
-
With login, please use the seed credentials provided in the UserController. They are
{ "Email":"[email protected]", "Password": "Tien12345" } or { "Email": "[email protected]", "Password": "Max12345" }
Login url: POST
[https://localhost:5001/api/users/login](https://localhost:5001/api/users/login)
Response body:
200 OK { "access_token": <jwt_token_here>, "email": <logged_in_email> }
-
-
Register
Register url: POST
[https://localhost:5001/api/users](https://localhost:5001/api/users/login)
Sample request body:
{ "Email": "[email protected]", "Password": "VerySecuredPassword" }
The Request body takes in a JSon object of type User, so
Email
andPassword
properties are string data type. No need to specifyId
as this is auto incremented by the server. ProvidedId
property in request body will be ignored
- In Postman, choose Authorization type as Oauth 2.0 if using Authorization tab. If using Headers, specify Key="Authorization" and Value=Bearer <your_access_token> (space between
Bearer
andaccess_token
) - update user account:
-
url: PUT
https://localhost:5001/api/users/<your_user_id>
-
Response body:
-
200 OK: User successfully updated
{ "Id": "<your_current_id>", "Email": "<updated_email_here>", "Password": "<updated_password_here>" }
-
401 Unauthorized: When user tries to update other user information
{ "error": "You are not authorized to update other user accounts!"}
-
400 BadRequest: id provided in url and request body doesn't match
{"error": "The provided ids don't match"}
-
-
Delete user account
- url: DELETE
https://localhost:5001/api/users/<your_user_id>
- Response body:
-
200 OK: User successfully deleted
{ "message" : "Your account has been removed!" }
-
401 Unauthorized: When user tries to delete other user information
{ "error": "You are not authorized to delete other user accounts!"}
-
404 User not found: id provided in url doesn't match any ids
{"error": "User not found!"}
-
- url: DELETE
-
- Get list of free rooms on date (without authorization needed):
- url: GET
https://localhost:5001/api/rooms/filter?date=<date>
- example:
https://localhost:5001/api/rooms/filter?date=02-05-2021
- url: GET
- Get list of all rooms with detailed reservation (bearer with access_token needed)
- url: GET
https://localhost:5001/api/rooms
- url: GET
- Get list of current user's reservations :
- url: GET
https://localhost:5001/api/reservations
- url: GET
- Update a reservation:
- url: PUT
https://localhost:5001/api/reservations/<id>
- url: PUT
- Create a reservation:
- url: POST
https://localhost:5001/api/reservations
- url: POST
- Delete a reservation:
- url: DELETE
https://localhost:5001/api/reservations/<id>
- url: DELETE