Product Category Service
Overview
The Product Category module manages the many-to-many relationship between Products and Categories.
It defines how products are assigned to categories and enables:
- category-based product listings
- navigation structures
- filtering and grouping of products
This module does not manage category definitions or product data itself. It only manages the relationship between them.
All operations are tenant-aware and fully audited.
Endpoints
GET
/api/v1/ProductCategory/GetAllProductsByCategoryId/{categoryId}
Returns a list of product IDs assigned to a given category.
Behavior:
- Returns only product IDs (not full product objects)
- Supports large datasets via internal batching
- Returns
404if no products are assigned to the category
Response:
List<long>- list of product identifiers
Authorization:
- Requires Bearer Token
POST
/api/v1/ProductCategory/AddNewProductCategory
Creates a relationship between a product and a category.
Query parameters:
productId(long, required)categoryId(long, required)
Behavior:
- Both product and category must exist
- Prevents duplicate relationships
- Writes an audit log entry on success
Errors:
- Returns
400if:- productId or categoryId is missing
- product does not exist
- category does not exist
- relationship already exists
Authorization:
- Requires Bearer Token
DELETE
/api/v1/ProductCategory/DeleteProductCategoriesByProductId/{productId}
Removes all categories assigned to a specific product.
Behavior:
- Deletes all ProductCategory relationships for the given product
- Uses EF relationship clearing (
product.Categories.Clear()) - Writes an audit log entry with the number of removed categories
Errors:
- Returns
400if:- product does not exist
- product has no categories assigned
Authorization:
- Requires Bearer Token
DELETE
/api/v1/ProductCategory/DeleteProductCategoriesByCategoryId/{categoryId}
Removes all products assigned to a specific category.
Behavior:
- Deletes all ProductCategory relationships for the given category
- Uses EF relationship clearing (
category.Products.Clear()) - Writes an audit log entry with the number of removed products
Errors:
- Returns
400if:- category does not exist
- category has no products assigned
Authorization:
- Requires Bearer Token
Notes
- This module manages relationships only
- No data duplication occurs
- Deletions affect only the relationship, not products or categories
- Large datasets are processed in batches to avoid memory pressure
- All state-changing operations are audited
- Internal errors are logged and not exposed to API consumers