#Magic Villa UI #Villa List Display #Create Villa
Welcome to the Magic Villa API project! This repository contains the source code for a robust API designed to manage villa-related operations efficiently. Built with ASP.NET Core, the API leverages Entity Framework Core for data access, AutoMapper for object mapping, and follows best practices for RESTful API design.
Magic Villa API provides a comprehensive solution for managing villas and villa numbers. It includes CRUD operations (Create, Read, Update, Delete) and utilizes DTOs (Data Transfer Objects) to ensure that data is handled securely and efficiently between the client and server.
- CRUD Operations: The API supports full CRUD operations for both villas and villa numbers.
- Error Handling: Robust error handling ensures that the API provides meaningful responses and logs errors for further analysis.
- AutoMapper Integration: Simplifies the mapping between entity models and DTOs.
- Async/Await: Asynchronous programming is used to enhance performance and scalability.
- Patch Support: Allows partial updates to resources using HTTP PATCH.
The project is organized into several key components:
-
VillaAPIController: Manages operations related to villas.
GetVillas()
: Retrieves all villas.GetVillaById(int id)
: Retrieves a specific villa by ID.CreateVilla(VillaCreateDTO villaDto)
: Creates a new villa.DeleteVilla(int id)
: Deletes a villa by ID.UpdateWithPut(int id, VillaUpdateDTO villaDto)
: Updates a villa entirely.UpdateWithPatch(int id, JsonPatchDocument<VillaUpdateDTO> patchDto)
: Partially updates a villa.
-
VillaNumberAPIController: Manages operations related to villa numbers.
GetVillaNumbers()
: Retrieves all villa numbers.GetVillaNumberById(int id)
: Retrieves a specific villa number by ID.CreateVillaNumber(VillaNumberDTO villaDto)
: Creates a new villa number.DeleteVillaNumber(int id)
: Deletes a villa number by ID.UpdateResponse(int id, VillaNumberDTO villaDto)
: Updates a villa number entirely.
- Villa: Represents the villa entity with properties such as
Id
,Name
,Description
,Rate
,sqft
,Occupancy
,ImageUrl
,Amenity
,CreatedDate
, andUpdatedDate
. - VillaNumber: Represents the villa number entity with properties such as
villaNo
,villaID
,Villa
,SpecialDetails
,CreatedDate
, andUpdatedDate
.
- VillaDTO: Data transfer object for the
Villa
model. - VillaCreateDTO: Used when creating a new villa.
- VillaUpdateDTO: Used when updating an existing villa.
- VillaNumberDTO: Data transfer object for the
VillaNumber
model. - VillaNumberCreateDTO: Used when creating a new villa number.
- VillaNumberUpdateDTO: Used when updating an existing villa number.
The mapping between entity models and DTOs is configured using AutoMapper in the MappingConfig
class.
- IVillaRepository: Defines the contract for villa-related data operations.
- IVillaNumberRepository: Defines the contract for villa number-related data operations.
-
Clone the repository:
git clone https://github.com/yourusername/magic-villa-api.git
-
Navigate to the project directory:
cd magic-villa-api
-
Restore the dependencies:
dotnet restore
-
Update the database:
dotnet ef database update
-
Run the application:
dotnet run
- GET /api/VillaAPI: Retrieve all villas.
- GET /api/VillaAPI/{id}: Retrieve a specific villa by ID.
- POST /api/VillaAPI: Create a new villa.
- DELETE /api/VillaAPI/{id}: Delete a villa by ID.
- PUT /api/VillaAPI/{id}: Update a villa entirely.
- PATCH /api/VillaAPI/{id}: Partially update a villa.
- GET /api/VillaNumberAPI: Retrieve all villa numbers.
- GET /api/VillaNumberAPI/{id}: Retrieve a specific villa number by ID.
- POST /api/VillaNumberAPI: Create a new villa number.
- DELETE /api/VillaNumberAPI/{id}: Delete a villa number by ID.
- PUT /api/VillaNumberAPI/{id}: Update a villa number entirely.
Contributions are welcome! Please fork this repository and submit pull requests.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or feedback, please open an issue or contact me at [email protected].
Thank you for exploring the Magic Villa API! Your contributions and feedback are greatly appreciated.