Skip to content

diegoperea20/Catalog-ASP.NET-10-Web-API-Sqlite

Repository files navigation

Catalog ASP.NET 10 Web API Sqlite

ASP.NET 10 Web API with Sqlite integration for catalog management.

Overview

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.

Tech Stack

  • .NET 10 - Web API framework
  • Sqlite - Database
  • Docker - Containerization

Getting Started

Prerequisites

Installation

  1. Clone the repository:
git clone <repository-url>
cd Catalog
  1. Create the ASP.NET Web API project:
dotnet new webapi -n Catalog --use-controllers
 dotnet run
 dotnet build

Run with environment variables

powershell -ExecutionPolicy Bypass -File .\run-with-env.ps1

Search packages or libraries

search packages or libraries in nuget

Create migration

 dotnet ef migrations add InitialCreate 

Update database

 dotnet ef database update

Set environment variable in terminal

 $env:ConnectionStrings__Catalog="Data Source=Production.db"

Use User Secrets secrets.json

 dotnet user-secrets init
 dotnet user-secrets set "ConnectionStrings:Catalog" "Data Source=Production.db"

Inspiration in youtube tutorial

Creation of project unit tests

dotnet new xunit -n Catalog.UnitTests

For add reference to Catalog project

dotnet add Catalog.UnitTests reference Catalog

execute all tests

dotnet test

Creation of solution of .slnx

dotnet new sln -n Catalog

ADD projects to solution

dotnet sln add Catalog
#for add unit tests project
dotnet sln add Catalog.UnitTests

Running the Application

Windows (PowerShell)

powershell -ExecutionPolicy Bypass -File .\run-with-env.ps1

Important: Ensure .gitignore is properly configured before running the script.

Cross-platform

dotnet run

API Documentation

The 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

API Testing Collections

The collections/ directory contains HTTP request files for testing the API using tools like Bruno or similar HTTP clients.

Available Collections

  • 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

Usage

  1. Import the collection files into your HTTP client
  2. Ensure the API is running on http://localhost:5195
  3. Execute requests to test API functionality

Project Structure

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

Configuration

Update appsettings.json with your MongoDB connection string:

{
  "MongoDbSettings": {
    "ConnectionString": "mongodb://localhost:27017",
    "DatabaseName": "Catalog"
  }
}

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


👨‍💻 Author / Autor

Diego Ivan Perea Montealegre


Created by Diego Ivan Perea Montealegre

About

ASP.NET 10 Web API with Sqlite integration for catalog management.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors