Skip to content
code-Alireza-codePublic

About

simple shop App backend

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Shop.Api

Shop.Api is a RESTful Web API built with ASP.NET Core and .NET 11.

It provides endpoints for managing product categories, products, and inventory in an e-commerce system.

Features

  • Category management
  • Product management
  • Inventory management
  • Input validation and centralized exception handling
  • SQL Server integration using ADO.NET

Tech Stack

  • Framework: ASP.NET Core 11
  • Language: C# 14
  • Database: Microsoft SQL Server
  • Data Access: ADO.NET (Microsoft.Data.SqlClient)
  • API Architecture: Controllers, Services, and Repositories
  • API Documentation: OpenAPI

Prerequisites

Before running the project, make sure you have installed:

  • .NET 11 SDK
  • Microsoft SQL Server
  • A SQL Server client (e.g. DbGate)

Database Setup

  1. Make sure Microsoft SQL Server is running.

  2. Create the Database Schema:

    Run the SQL script located at:

Shop.Api/Database/schema.sql

This script creates the Shop database, including all tables, constraints, and foreign key relationships.

The database contains the following tables:

  • Categories
  • Products
  • Inventory

Configuration

The application uses the DefaultConnection connection string to connect to SQL Server.

For local development, configure it using .NET User Secrets:

  1. Initialize User Secrets:

    dotnet user-secrets init
  2. Set the connection string:

    dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=localhost;Database=Shop;User Id=YOUR_USER_NAME;Password=YOUR_PASSWORD;TrustServerCertificate=True"

Replace YOUR_USER_NAME and YOUR_PASSWORD with your SQL Server password.

Note: Never commit database credentials or secrets to source control.

Running the API

  1. Clone the repository:

    git clone YOUR_REPOSITORY_URL
  2. Navigate to the project directory:

    cd Shop.Api
  3. Restore dependencies:

    dotnet restore
  4. Build the project:

    dotnet build
  5. Run the application:

    dotnet run

API Endpoints

Categories

Method Endpoint Description
GET /api/Categories Get all categories
GET /api/Categories/{id} Get a category by ID
POST /api/Categories Create a category
PUT /api/Categories/{id} Update a category
DELETE /api/Categories/{id} Delete a category

Products

Method Endpoint Description
GET /api/Products Get all products
GET /api/Products/{id} Get a product by ID
POST /api/Products Create a product
PUT /api/Products/{id} Update a product
DELETE /api/Products/{id} Delete a product

Inventory

Method Endpoint Description
GET /api/Inventory/{productId} Get inventory for a product
POST /api/Inventory Create inventory
PUT /api/Inventory/{productId} Update inventory
DELETE /api/Inventory/{productId} Delete inventory

About

simple shop App backend

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages