This readme contains information for the ASP.NET Core WebApi hands-on exercise.
The goal of this hands-on exercise is to implement a REST-based API for the booking department of the Forkus Hotel. This document will provide a specification of API calls with expected results and it will be up to you to implement them. You can then use tests to test if your implementation follows the spec.
The solution includes a test-project for the API. The test suite is not complete for all the assignments. Run this either through the Visual Studio Test Explorer or from the command-line using:
dotnet test
Note: current directory must be in the integration-tests project folder for the command to work.
There is a postman collection "postman_collection.json" at the root of the repo that has pre-defined requests for the same scenarios as the integration tests.
The "ForkusHotel.Api.Solution"-folder contains suggested solutions for the first part of the assignment. It is not complete. Tests and postman-collection should work as specified with the solution project.
What follows is the specification for the API. To keep it simple don't worry about JSON serialization details (like dates). These are up to your implementation
- Route: /api/booking/roomtypes
- Method: Get
- Status: 200 - Ok
- JSON Body:
{ "roomTypes" : [
"Single", "Double", "Twin",
"DeluxeDouble", "JuniorSuite", "Suite",
"ForkusSuite"
]}
- Route: /api/booking/bookings
- Method: Post
- JSON Body(example):
{
"roomType" : "ForkusSuite",
"startDate" : "2016-10-21T13:28:06.419Z",
"numberOfNights" : "3",
"guestName" : "Kjell Lj0stad"
}
- Status: 201 - Created
- Location header: /api/booking/bookings/{newBookingId}
- JSON Body(example):
{ "bookingId" : "{newBookingId}" }
- Status: 400 - Bad request
- JSON Body:
{ "error" : "Unknown room-type specified" }
- Status: 400 - Bad request
- JSON Body:
{ "error" : "Specified time period is invalid" }
- Staus: 409 - Conflict
- Route: /api/booking/bookings
- Method: Get
- Status: 200 - Ok
- JSON Body(example):
{
"bookings" : [
{
"bookingId" : "2B121B48-FD3D-4E14-89E9-11EC009F57C7",
"roomType" : "ForkusSuite",
"startDate" : "2016-10-21T13:28:06.419Z",
"numberOfNights" : "3",
"guestName" : "Rupert Giles"
},
{
"bookingId" : "02841435-1A78-4EFD-8581-1BB8A0B098A9",
"roomType" : "JuniorSuite",
"startDate" : "2016-10-21T13:28:06.419Z",
"numberOfNights" : "2",
"guestName" : "Jean-Luc Picard"
}]
}
- Route: /api/booking/bookings/{bookingId}
- Method: Get
- Status: 200 - Ok
- JSON Body(example):
{
"roomType" : "ForkusSuite",
"startDate" : "2016-10-21T13:28:06.419Z",
"numberOfNights" : "3",
"guestName" : "Kjell Lj0stad",
"paymentConfirmed" : false,
"checkedIn" : true,
"checkedOut" : false
}
- Status: 404 - Not found
- Route: /api/booking/bookings/{bookingId}
- Method: Delete
- Status: 204 - No Content
- Status: 404 - Not found
- Route: /api/booking/bookings/{bookingId}/roomtype
- Method: Put
- JSON Body(example):
{ "newRoomType" : "ForkusSuite" }
- Status: 204 - No content
- Status: 404 - Not found
- Status: 404 - Not found
- JSON Body:
{ "error" : "Unknown room-type" }
- Route: /api/booking/bookings/{bookingId}/checkin
- Method: Put
- Status: 204 - No content
- Status: 404 - Not found
- Status: 404 - Not found
- JSON Body:
{ "error" : "Already checked in" }
- Route: /api/booking/bookings/{bookingId}/checkout
- Method: Put
- Status: 204 - No content
- Status: 404 - Not found
- Status: 404 - Not found
- JSON Body:
{ "error" : "Already checked out" }
Happy coding!