Build a Complete Product CRUD API with ASP.NET Core (.NET 10)

In This Article
- Overview
- What you’ll get
- Typical use cases
- Product Model
- Why this design?
- ProductController (Complete CRUD)
- Key highlights
- CRUD Operations Explained (Quick)
- Create (POST /product)
- Read All (GET /product)
- Read by ID (GET /product/{id})
- Update (PUT /product/{id})
- Delete (DELETE /product/{id})
- API Endpoints
- Testing Options
- Swagger Setup (Program.cs)
Creating a clean, well-documented CRUD API is a foundational skill for modern backend development. In this guide, we’ll walk through a production-ready Product CRUD API built with ASP.NET Core Web API (.NET 10, C# 14)—covering design principles, full controller logic, testing, Swagger integration, and clear next steps for scaling to production.
Overview
This API demonstrates RESTful best practices using a simple in-memory store to keep the focus on clarity and correctness. It’s ideal for learning, demos, interviews, and as a starting point for real projects.
What you’ll get
- Full CRUD operations (Create, Read, Update, Delete)
- Clean REST endpoints and named routes
- Correct HTTP status codes
- Strongly-typed responses
- Swagger/OpenAPI for instant testing
- Clear testing workflows (.http, Swagger, Postman)
Typical use cases
- E-commerce product catalogs
- Inventory management systems
- Mobile app backends
- Third-party integrations
Product Model
Location: CRUD Operation/Product.cs namespace CRUD_Operation
{
public class Product
{
public int Id { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
public decimal Price { get; set; }
public int Stock { get; set; }
public string? Category { get; set; }
}
} 

