Skip to content

diegoperea20/Simple-API-REST-ASP.NET-10

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple API REST ASP.NET 10

A simple API REST using ASP.NET 10, Entity Framework Core , SQLite and Testing with xUnit.

API Endpoints (Bruno Collections)

The API endpoints are available in the collections folder using Bruno for testing and documentation.

🎮 Games Endpoints

Base URL: http://localhost:5187/games

  • GET /games - Get all games
  • GET /games/{id} - Get game by ID
  • POST /games - Create new game
    {
      "name": "Game Name",
      "genreId": 1,
      "price": 59.99,
      "releaseDate": "2023-10-20"
    }
  • PUT /games/{id} - Update existing game
  • DELETE /games/{id} - Delete game by ID

🎭 Genres Endpoints

Base URL: http://localhost:5187/genres

  • GET /genres - Get all genres
  • GET /genres/{id} - Get genre by ID
  • POST /genres - Create new genre
    {
      "name": "Genre Name"
    }
  • PUT /genres/{id} - Update existing genre
  • DELETE /genres/{id} - Delete genre by ID

📁 Bruno Collection Structure

collections/
├── Games/
│   ├── get all games.bru
│   ├── get id games.bru
│   ├── create game.bru
│   ├── update game id.bru
│   └── delete game id.bru
├── Genres/
│   ├── get all genres.bru
│   ├── get id genres.bru
│   ├── create genre.bru
│   ├── update genre id.bru
│   └── delete genre id.bru
└── bruno.json

Creation of project

dotnet new web -n <nameproject>
 dotnet run
 dotnet build

search packages or libraries in nuget

create migration

 dotnet ef migrations add InitialCreate --output-dir Data\Migrations

update database

 dotnet ef database update

in terminal put enviroment variable powershell

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

o use User Secrets secrets.json

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

Inspiration in youtube tutorial

Creation of project unit tests

dotnet new xunit -n GameStore.UnitTests

For add reference to GameStore project

dotnet add GameStore.UnitTests reference GameStore

execute all tests

dotnet test

Creation of solution of .slnx

dotnet new sln -n GameStore

ADD projects to solution

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

📄 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

A simple API REST using ASP.NET 10, Entity Framework Core , SQLite and Testing with xUnit.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages