This API provides a range of endpoints designed for the management of various hotel-related tasks, including booking handling, hotel and city information management, and offering guest services.
- User Registration: Allows new users to create accounts by providing necessary information.
- User Login: Enables registered users to log in securely to access booking features.
- Search by Various Criteria: Users can search for hotels using criteria such as hotel name, room type, room capacities, price range, and other properties through text fields.
- Comprehensive Search Results: Provides users with detailed information about hotels matching their search criteria.
- Management of Images and Thumbnails: Allows for the addition, deletion, and updating of images associated with cities, hotels, and rooms.
- Display Most Visited Cities: Showcases popular cities based on user traffic, allowing users to explore trending destinations easily.
- Booking Confirmation Emails: Sends confirmation emails to users upon successful booking, containing essential information such as total price, hotel location on the map, and other relevant details.
- Enhanced User Communication: Facilitates effective communication with users, keeping them informed about their bookings.
- Search, Add, Update, and Delete Entities: Provides administrators with full control over system entities, enabling efficient management of cities, hotels, rooms, and other components.
- Streamlined Administrative Tasks: Simplifies administrative tasks through a user-friendly interface, enhancing system maintenance.
HTTP Method | Endpoint | Description |
---|---|---|
GET | /api/amenities | Retrieve a page of amenities |
POST | /api/amenities | Create a new amenity |
GET | /api/amenities/{id} | Get an amenity specified by ID |
PUT | /api/amenities/{id} | Update an existing amenity |
HTTP Method | Endpoint | Description |
---|---|---|
POST | /api/auth/login | Processes a login request |
POST | /api/auth/register-guest | Processes registering a guest request |
HTTP Method | Endpoint | Description |
---|---|---|
POST | /api/user/bookings | Create a new Booking for the current user |
GET | /api/user/bookings | Get a page of bookings for the current user |
DELETE | /api/user/bookings/{id} | Delete an existing booking specified by ID |
GET | /api/user/bookings/{id} | Get a booking specified by ID for the current user |
GET | /api/user/bookings/{id}/invoice | Get the invoice of a booking specified by ID as PDF for the current user |
HTTP Method | Endpoint | Description |
---|---|---|
GET | /api/cities | Retrieve a page of cities |
POST | /api/cities | Create a new city |
GET | /api/cities/trending | Returns TOP N most visited cities (trending cities) |
PUT | /api/cities/{id} | Update an existing city specified by ID |
DELETE | /api/cities/{id} | Delete an existing city specified by ID |
PUT | /api/cities/{id}/thumbnail | Set the thumbnail of a city specified by ID |
HTTP Method | Endpoint | Description |
---|---|---|
GET | /api/room-classes/{roomClassId}/discounts | Retrieve a page of discounts for a room class |
POST | /api/room-classes/{roomClassId}/discounts | Create a discount for a room class specified by ID |
GET | /api/room-classes/{roomClassId}/discounts/{id} | Get an existing discount by ID |
PUT | /api/room-classes/{roomClassId}/discounts/{id} | Delete an existing discount specified by ID |
HTTP Method | Endpoint | Description |
---|---|---|
GET | /api/user/recently-visited-hotels | Retrieve the recently N visited hotels by the current user |
HTTP Method | Endpoint | Description |
---|---|---|
GET | /api/hotels | Retrieve a page of hotels |
POST | /api/hotels | Create a new hotel |
GET | /api/hotels/search | Search and filter hotels based on specific criteria |
GET | /api/hotels/featured-deals | Retrieve N hotel featured deals |
GET | /api/hotels/{id} | Get hotel by ID for guest |
PUT | /api/hotels/{id} | Update an existing hotel specified by ID |
DELETE | /api/hotels/{id} | Delete an existing hotel specified by ID |
GET | /api/hotels/{id}/room-classes | Get room classes for a hotel specified by ID for Guests |
PUT | /api/hotels/{id}/thumbnail | Set the thumbnail of a hotel specified by ID |
POST | /api/hotels/{id}/gallery | Add a new image to a hotel's gallery specified by ID |
HTTP Method | Endpoint | Description |
---|---|---|
GET | /api/owners | Retrieve a page of owners |
POST | /api/owners | Create a new owner |
GET | /api/owners/{id} | Get an existing owner by ID |
PUT | /api/owners/{id} | Update an existing owner |
HTTP Method | Endpoint | Description |
---|---|---|
GET | /api/hotels/{hotelId}/reviews | Retrieve a page of reviews for a hotel specified by ID |
POST | /api/hotels/{hotelId}/reviews | Create a new review for a hotel specified by ID |
GET | /api/hotels/{hotelId}/reviews/{id} | Get a review specified by ID for a hotel specified by ID |
PUT | /api/hotels/{hotelId}/reviews/{id} | Update an existing review specified by ID for a hotel specified by ID |
DELETE | /api/hotels/{hotelId}/reviews/{id} | Delete an existing review specified by ID for a hotel specified by ID |
HTTP Method | Endpoint | Description |
---|---|---|
GET | /api/room-classes | Retrieve a page of room classes |
POST | /api/room-classes | Create a new room class |
PUT | /api/room-classes/{id} | Update an existing room class specified by ID |
DELETE | /api/room-classes/{id} | Delete an existing room class specified by ID |
POST | /api/room-classes/{id}/gallery | Add a new image to a room class's gallery specified by ID |
HTTP Method | Endpoint | Description |
---|---|---|
GET | /api/room-classes/{roomClassId}/rooms | Retrieve a page of rooms for a room class |
POST | /api/room-classes/{roomClassId}/rooms | Create a new room in a room class specified by ID |
GET | /api/room-classes/{roomClassId}/rooms/available | Retrieve a page of available rooms for a room class |
PUT | /api/room-classes/{roomClassId}/rooms/{id} | Update an existing room with ID in a room class specified by ID |
DELETE | /api/room-classes/{roomClassId}/rooms/{id} | Delete a room by ID in a room class specified by ID |
- Clean Architecture
- External Layers:
- Web: Controllers for handling requests and managing client-server communication.
- Infrastructure: Manages external resources such as databases, email service, PDF generation, image service, and auth management.
- Core Layers:
- Application Layer: Implements business logic and orchestrates interactions between components.
- Domain Layer: Contains fundamental business rules and entities, independent of external concerns like databases or user interfaces.
- External Layers:
- C#: Main programming language.
- ASP.NET Core: Framework for building high-performance, cross-platform web APIs.
- Entity Framework Core: Employing Entity Framework Core for streamlined object-relational mapping (ORM) within the .NET ecosystem, simplifying database interactions.
- SQL Server: Utilizing SQL Server for reliable and scalable backend database management, ensuring efficient storage and retrieval of application data.
- Firebase Storage: Part of Google's Firebase platform, offers cloud-based storage for images in this hotel booking system. It provides scalability, reliability, and seamless API integration.
- Swagger/OpenAPI: For API specification and documentation.
- Swagger UI: Provides a user-friendly interface for API interaction.
- JWT (JSON Web Tokens): For secure transmission of information between parties.
- Serilog: Logging library for .NET applications.
- RESTful Principles: Adhering to RESTful design principles to ensure that APIs are designed for simplicity, scalability, and ease of use.
- Repository Pattern: Implementing the repository pattern to abstract the data layer, enhancing application maintainability, testability, and cleanliness by decoupling data access logic from business logic.
- Options Pattern: For efficient configuration management within the application.
- Unit of Work: Manages transactions across multiple data operations, ensuring atomicity and data consistency within a single logical unit.
- Data Encryption: Password hashing using
Microsoft.AspNet.Identity.IPasswordHasher
.
This API leverages the Asp.Versioning.Mvc
library to implement a streamlined header-based versioning mechanism. This approach facilitates seamless client access to different API versions without requiring adjustments to the base URL or path. By utilizing headers, the versioning process is standardized, offering improved clarity and maintainability. This method also enhances flexibility and ease of integration for users while ensuring optimal compatibility with various client applications.
Users can effortlessly specify their preferred API version by including the x-api-version header in their requests. In instances where no version is explicitly specified, the API seamlessly defaults to the latest available version. For instance:
To explicitly request version 1.0:
curl -X GET "localhost:8080/api/cities" -H "x-api-version: 1.0"
To utilize the latest version by default:
curl -X GET "localhost:8080/api/cities"
This guide provides instructions on setting up an existing ASP.NET API project. Follow these steps to clone the repository, configure the appsettings.json
file, and run the API locally.
- .NET 8 SDK installed on your system.
- Running SQL Server instance with a database.
Clone the repository of your existing ASP.NET API project to your local machine:
git clone https://github.com/Nedal-Esrar/Travel-and-Accommodation-Booking-Platform.git
Change your current directory to the root directory of your ASP.NET API project:
cd Travel-and-Accommodation-Booking-Platform/src/TABP.Api
Open the appsettings.json
file located in your project directory and configure the connection string for SQL Server. Replace the <connection_string>
placeholder with your SQL Server connection string:
{
"ConnectionStrings": {
"SqlServer": "<connection_string>"
}
}
Start the ASP.NET API project using the following command:
dotnet run
The API will be accessable using http://localhost:8080.
The swagger UI will open automatically where you can try and explore the endpoints or you can open it using http://localhost:8080/swagger.
- Email: [email protected]
- Password: 11aaAA@@
Your Feedback and Contributions are Welcome!
- Feedback: Share your thoughts and ideas.
- Issue Reporting: Help us by reporting any bugs or issues on GitHub.
- Code Contributions: Contribute to the codebase.
Email: [email protected].
GitHub: Nedal-Esrar.
Thank you for your interest. I look forward to hearing from you!