Welcome to the GameStore API! This is a RESTful API built with ASP.NET Core for managing a store of video games and their genres.
- Features
- Prerequisites
- Installation
- Database Setup
- Running the Application
- API Endpoints
- Testing the API
- Project Structure
- Contributing
- CRUD Operations: Full Create, Read, Update, Delete for games.
- Entity Framework Core: SQLite database with EF Core migrations.
- Minimal API: Lightweight endpoints with ASP.NET Core Minimal APIs.
- DTOs & Validation: Data transfer objects with model validation.
# Clone repository
git clone https://github.com/abdullokhonz/GameStore.git
# Navigate to project directory
cd GameStore
# Restore dependencies
dotnet restore
If you don't have the EF Core tools installed, run:
dotnet tool install --global dotnet-ef
Run the following command to create the database and apply migrations:
dotnet ef database update --project GameStore.Api
This will:
- Create the SQLite database file (
GameStore.db
) in theGameStore.Api
folder. - Apply all EF Core migrations.
- Seed initial data (if any).
# Start the API
dotnet run --project GameStore.Api
# API will be available at:
# - HTTP: http://localhost:5000
# - HTTPS: https://localhost:5001
Method | Endpoint | Description |
---|---|---|
GET | /games |
Get all games |
GET | /games/{id} |
Get game by ID |
POST | /games |
Create a new game |
PUT | /games/{id} |
Update a game |
DELETE | /games/{id} |
Delete a game |
Method | Endpoint | Description |
---|---|---|
GET | /genres |
Get all genres |
GET | /genres/{id} |
Get genre by ID |
- Install the REST Client extension for VS Code.
- Open the
.http
files in theGameStore.Api
folder:games.http
for testing game endpoints.genres.http
for testing genre endpoints.
- Click the Send Request button above each request to test the endpoints.
Example Request:
### Get all games
GET http://localhost:5000/games
Accept: application/json
### Create a new game
POST http://localhost:5000/games
Content-Type: application/json
{
"name": "Cyberpunk 2077",
"genreId": 1,
"price": 59.99,
"releaseDate": "2020-12-10"
}
GameStore/
├── .gitignore # Git ignore file
├── GameStore.sln # Visual Studio solution file
├── GameStore.Api/ # Main API project
│ ├── Data/ # Database context and migrations
│ │ ├── GameStoreContext.cs
│ │ └── Migrations/
│ ├── Dtos/ # Data transfer objects
│ │ ├── CreateGameDto.cs
│ │ ├── GameDetailsDto.cs
│ │ └── UpdateGameDto.cs
│ ├── Endpoints/ # API endpoints
│ │ ├── GamesEndpoints.cs
│ │ └── GenresEndpoints.cs
│ ├── Entities/ # Database entities
│ │ ├── Game.cs
│ │ └── Genre.cs
│ ├── Mapping/ # Mapping configurations
│ │ ├── GameMapping.cs
│ │ └── GenreMapping.cs
│ ├── appsettings.json # Configuration file
│ ├── Program.cs # Entry point of the application
│ └── GameStore.db # SQLite database file
└── README.md # Project documentation
- Fork the repository:
- Click the "Fork" button on the GitHub repository page.
- Create a feature branch:
git checkout -b feature/your-feature-name
- Commit your changes:
git commit -m "Add: Description of your changes"
- Push to the branch:
git push origin feature/your-feature-name
- Open a Pull Request:
- Go to the original repository on GitHub and click "New Pull Request".
Happy coding! 🚀
Let's build something awesome together! 💻🎮