Skip to content

GameStore API - A simple REST API for managing video games and genres. Built with ASP.NET Core, Entity Framework Core, and SQLite. Great for beginners and small projects.

Notifications You must be signed in to change notification settings

abdullokhonz/GameStore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

GameStore API

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.


Table of Contents

  1. Features
  2. Prerequisites
  3. Installation
  4. Database Setup
  5. Running the Application
  6. API Endpoints
  7. Testing the API
  8. Project Structure
  9. Contributing

Features

  • 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.

Prerequisites


Installation

# Clone repository
git clone https://github.com/abdullokhonz/GameStore.git

# Navigate to project directory
cd GameStore

# Restore dependencies
dotnet restore

Database Setup

1. Install Entity Framework Core Tools

If you don't have the EF Core tools installed, run:

dotnet tool install --global dotnet-ef

2. Apply Migrations

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 the GameStore.Api folder.
  • Apply all EF Core migrations.
  • Seed initial data (if any).

Running the Application

# Start the API
dotnet run --project GameStore.Api

# API will be available at:
# - HTTP: http://localhost:5000
# - HTTPS: https://localhost:5001

API Endpoints

🎮 Games

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

🗂️ Genres

Method Endpoint Description
GET /genres Get all genres
GET /genres/{id} Get genre by ID

Testing the API

Using .http Files

  1. Install the REST Client extension for VS Code.
  2. Open the .http files in the GameStore.Api folder:
    • games.http for testing game endpoints.
    • genres.http for testing genre endpoints.
  3. 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"
}

Project Structure

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

Contributing

  1. Fork the repository:
    • Click the "Fork" button on the GitHub repository page.
  2. Create a feature branch:
    git checkout -b feature/your-feature-name
  3. Commit your changes:
    git commit -m "Add: Description of your changes"
  4. Push to the branch:
    git push origin feature/your-feature-name
  5. Open a Pull Request:
    • Go to the original repository on GitHub and click "New Pull Request".

Happy coding! 🚀
Let's build something awesome together! 💻🎮

About

GameStore API - A simple REST API for managing video games and genres. Built with ASP.NET Core, Entity Framework Core, and SQLite. Great for beginners and small projects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages