Author: Kyungrae Kim
Endpoint: https://asyncinn.herokuapp.com
- Lab 18 - Roles
- Lab 17 - Identity
- Lab 14 - Navigation Properties & Routing
- Lab 13 - Dependency Injection
- Lab 12 - Intro to Entity Framework Core and APIs
This is a RESTful API server built using ASP.NET Core to allow Async Hotel management to better manage the assets in their hotels. This application can modify and manage rooms, amenities, and new hotel locations. The data entered by the user will persist across a relational database and maintain its integrity as changes are made to the system.
The Below is link to the MVC web application version of the assignment:
https://github.com/jeremymaya/Code-401-Async-Inn
Clone this repository to your local machine.
git clone https://github.com/jeremymaya/Code-401-Async-Inn-API.git
Select File
-> Open
-> Code-401-Async-Inn-API
Next navigate to the location you cloned the Repository.
Double click on the AsyncInnAPI
directory.
Then select and open AsyncInnAPI.sln
Diagram Credit: Amanda Iverson
- Hotel table has one to many relationship with HotelRoom table
- Room table has one to many relationship with HotelRoom table
- Amenities table has one to many relationship with RoomAmenities table
- HotelRoom table is a joint table with a payload
- RoomAmenities table is a pure join table
- Layout is an enum
- RESTful API
- Entity Framework Core
- Dependency Injection
- Data Transfer Objects
- Identity
- Authorization
- JSON Web Token (JWT)
Method | EndPoint | Description |
---|---|---|
POST | /api/Account/Register |
|
POST | /api/Account/Assign/Role |
|
POST | /api/Account/Login |
Sample Request Body of POST /api/Account/Register
{
"email": "[email protected]",
"password": "string",
"firstName": "string",
"lastName": "string",
"role": "string"
}
Method | EndPoint | Description |
---|---|---|
GET | /api/Amenities |
|
POST | /api/Amenities |
|
GET | /api/Amenities/{id} |
|
PUT | /api/Amenities/{id} |
|
DELETE | /api/Amenities/{id} |
Sample Response of GET /api/Amenities
[
{
"id": 0,
"name": "string"
}
]
Method | EndPoint | Description |
---|---|---|
GET | /api/Hotels/{hotelId}/Rooms |
|
POST | /api/Hotels/{hotelId}/Rooms |
|
GET | /api/Hotels/{hotelId}/Rooms/{roomNumber} |
|
PUT | /api/Hotels/{hotelId}/Rooms/{roomNumber} |
|
DELETE | /api/Hotels/{hotelId}/Rooms/{roomNumber} |
Sample Response of GET /api/Hotels/{hotelId}/Rooms
[
{
"hotelId": 0,
"roomNumber": 0,
"rate": 0,
"petFriendly": true,
"roomId": 0,
"room": {
"id": 0,
"name": "string",
"layout": "string",
"amenities": [
{
"id": 0,
"name": "string"
}
]
}
}
]
Method | EndPoint | Description |
---|---|---|
GET | /api/Hotels |
|
POST | /api/Hotels |
|
GET | /api/Hotels/{id} |
|
PUT | /api/Hotels/{id} |
|
DELETE | /api/Hotels/{id} |
Sample Response of GET /api/Hotels
[
{
"id": 0,
"name": "string",
"streetAddress": "string",
"city": "string",
"state": "string",
"phone": "string",
"rooms": [
{
"hotelId": 0,
"roomNumber": 0,
"rate": 0,
"petFriendly": true,
"roomId": 0,
"room": {
"id": 0,
"name": "string",
"layout": "string",
"amenities": [
{
"id": 0,
"name": "string"
}
]
}
}
]
}
]
Method | EndPoint | Description |
---|---|---|
GET | /api/Rooms/ |
|
POST | /api/Rooms/ |
|
GET | /api/Rooms/{id} |
|
PUT | /api/Rooms/{id} |
|
DELETE | /api/Rooms/{id} |
|
POST | /api/Rooms/{roomId}/Amenity/{amenityId} |
|
DELETE | /api/Rooms/{roomId}/Amenity/{amenityId} |
Sample Response of GET /api/Rooms
[
{
"id": 0,
"name": "string",
"layout": "string",
"amenities": [
{
"id": 0,
"name": "string"
}
]
}
]
Go to ASP.NET Core Development with macOS for more details.
If you have not already, download the Docker Desktop for Mac.
-
Download Postgres with the following command:
docker pull postgres:latest
-
Launch the Docker Image with the following command:
docker run --name psql -e POSTGRES_USER=sa -e POSTGRES_PASSWORD=ReallyStrongPassword1234! -p 5432:5432 -d postgres
-
Update the connection string with the following:
"ConnectionStrings": { "DefaultConnection": "Host=localhost;Database=DbName;Username=sa;Password=ReallyStrongPassword1234!" }
-
Add a dependency on
Npgsql.EntityFrameworkCore.PostgreSQL
- Github - Amanda Iverson
- ASP.NET Core Development with macOS
- Documenting API endpoints - Documentation
- The Code Buzz - ASP.NET Core 3.1 – Use JWT Authorization Token in Swagger(OpenAPI)
- Docker Hub - postgres
- Hacker Noon - How To Install PostgreSQL With Docker Quickly
- Npgsql Doc - Entity Framework Core
- Code Maze - How to Configure PostgreSQL in Entity Framework Core
- medium@RobertKhou - Getting Started with Entity Framework Core (PostgreSQL)
- 1.7: Deployed to Heroku - 12 October 2020
- 1.6: Lab 18 Completed - 5 Aug 2020
- 1.5: Lab 17 Completed - 3 Aug 2020
- 1.4: Lab 16 Completed - 2 Aug 2020
- 1.3: Lab 14 Completed - 30 Jul 2020
- 1.2: Lab 13 Completed - 30 Jul 2020
- 1.1: Lab 12 Completed - 29 Jul 2020