This project provides a RESTful API for managing orders in a SQL database. It allows clients to create, retrieve, update, and delete orders. Built using ASP.NET Core, this API demonstrates best practices in handling database operations and API design.
- CRUD operations for orders:
- Create: Add new orders to the system.
- Read: Retrieve existing orders.
- Update: Modify details of existing orders.
- Delete: Remove orders from the database.
- Secure and efficient database interaction with parameterized queries.
- Integration of Swagger for API documentation and testing.
- ASP.NET Core: For creating the web API.
- Dapper: As a micro-ORM to handle database operations.
- Microsoft.Data.SqlClient: For database connectivity.
- Swashbuckle (Swagger): For API documentation.
- .NET 6.0 or higher
- SQL Server (any recent version)
- Visual Studio or VS Code
- Clone the repository: git clone [repository-url]
sql
Copy code
2. Open the solution in Visual Studio or VS Code.
3. Update the connection string in appsettings.json
to match your SQL Server instance:
"ConnectionStrings": {
"DefaultConnection": "Server=your_server;Database=your_database;User Id=your_username;Password=your_password;"
}
Build the project to restore the necessary packages.
Running the application
Use the following command to run the application:
arduino
Copy code
dotnet run
Navigate to http://localhost:5000/swagger to view and interact with the API documentation.
API Endpoints
All API responses are in JSON format. Below are the endpoints provided by this API:
GET /orders: Retrieves all orders.
GET /orders/{id}: Retrieves a specific order by ID.
POST /orders: Adds a new order.
PUT /orders/{id}: Updates an existing order.
DELETE /orders/{id}: Deletes an order.
Testing
You can test the API endpoints using Swagger UI or tools like Postman.
Contributions
Contributions are welcome. Please fork this repository and submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
css
Copy code
Feel free to modify the contents to better suit your project's specifics or to ref