ASP.NET 10 Web API with Sqlite integration for catalog management.
This project provides a RESTful API for managing catalog items using ASP.NET Core and Sqlite. It includes CRUD operations, Docker containerization, and comprehensive API testing collections.
- .NET 10 - Web API framework
- Sqlite - Database
- Docker - Containerization
- .NET 10 SDK
- Docker Desktop
- PowerShell (for Windows)
- Git Same project but using mongo Catalog-ASP.NET-10-Web-API-MongoDB
- Clone the repository:
git clone <repository-url>
cd Catalog- Create the ASP.NET Web API project:
dotnet new webapi -n Catalog --use-controllers dotnet run dotnet buildpowershell -ExecutionPolicy Bypass -File .\run-with-env.ps1search packages or libraries in nuget
dotnet ef migrations add InitialCreate dotnet ef database update $env:ConnectionStrings__Catalog="Data Source=Production.db" dotnet user-secrets init
dotnet user-secrets set "ConnectionStrings:Catalog" "Data Source=Production.db"Inspiration in youtube tutorial
dotnet new xunit -n Catalog.UnitTestsFor add reference to Catalog project
dotnet add Catalog.UnitTests reference Catalogexecute all tests
dotnet testdotnet new sln -n CatalogADD projects to solution
dotnet sln add Catalog
#for add unit tests project
dotnet sln add Catalog.UnitTestspowershell -ExecutionPolicy Bypass -File .\run-with-env.ps1Important: Ensure
.gitignoreis properly configured before running the script.
dotnet runThe API provides the following endpoints:
| Method | Endpoint | Description |
|---|---|---|
| GET | /items |
Retrieve all items |
| GET | /items/{id} |
Retrieve item by ID |
| POST | /items |
Create new item |
| PUT | /items/{id} |
Update existing item |
| DELETE | /items/{id} |
Delete item by ID |
The collections/ directory contains HTTP request files for testing the API using tools like Bruno or similar HTTP clients.
- get all.yml - Retrieve all catalog items
- get id item.yml - Retrieve specific item by ID
- post item.yml - Create new catalog item
- put id item.yml - Update existing item
- delete id item.yml - Delete item by ID
- opencollection.yml - Collection configuration file
- Import the collection files into your HTTP client
- Ensure the API is running on
http://localhost:5195 - Execute requests to test API functionality
Catalog/
|-- README.md
|-- collections/ # API testing collections
| |-- get all.yml
| |-- get id item.yml
| |-- post item.yml
| |-- put id item.yml
| |-- delete id item.yml
| |-- opencollection.yml
| |-- .gitignore
|-- Controllers/ # API controllers
|-- Models/ # Data models
|-- Services/ # Business logic
|-- appsettings.json # Configuration
|-- run-with-env.ps1 # Windows execution script
Update appsettings.json with your MongoDB connection string:
{
"MongoDbSettings": {
"ConnectionString": "mongodb://localhost:27017",
"DatabaseName": "Catalog"
}
}- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Diego Ivan Perea Montealegre
- GitHub: @diegoperea20
Created by Diego Ivan Perea Montealegre