Skip to content

ShaneFreeman-Solution-PR#127

Open
Sketarius wants to merge 10 commits into
Jcouls29:masterfrom
Sketarius:sfreeman-branch
Open

ShaneFreeman-Solution-PR#127
Sketarius wants to merge 10 commits into
Jcouls29:masterfrom
Sketarius:sfreeman-branch

Conversation

@Sketarius

Copy link
Copy Markdown

This implementation was planned and developed with the assistance of Claude (Anthropic AI).
Claude helped architect the solution, enforce best practices (Micosoft C# Coding Conventions), and ensure consistency across all layers of the application.

Analysis of project requirements, database schema and the available libraries were performed.
The project was broken down into 4 main commits with some touch-ups afterward.

Every feature was written with Test Driven Development in mind as tests were written first, then the implementations were written to make them pass. The test project contains 16 tests across the service layer.

The architecture I followed was a strict Controller -> Service -> Repo pattern.

SOLID principles were applied throughout.
Each class has one job.
SqlServerQueryProvider extended via methods, no modifications.
ISqlExecutor implementations are interchangeable.
Product and Inventory interfaces are separate.
All dependances injected as interfaces.

Every change was reviewed before implemented.

3rd party libraries used:
Swashbuckle - For API documentation w/ Swagger
xUnit - For Unit Testing
Moq - Used in unit testing to isolate the service layer from the database.

Sketarius added 10 commits June 4, 2026 12:14
- Add xUnit + Moq test project wired to Interview.Web
- Add CreateProductRequest model with attributes and category support
- Add CreateAsync to IProductRepository and IProductsService
- Register ISqlExecutor, IProductRepository, IProductsService in DI
- Bind SqlServerOptions connection string from appsettings.json
- Clean up ProductController - inject IProductsService, remove misplaced query logic
- Stub repository and service methods to drive TDD in subsequent milestones
…gories

- Implement ProductsService.CreateAsync with input validation via PreConditions
- Validate Name and Description against DB column length limits (256 chars)
- Implement ProductRepository.CreateAsync with three transactional inserts
- Insert product, attributes, and categories atomically - rolls back on failure
- Use SCOPE_IDENTITY() to capture generated InstanceId for child table inserts
- Add 6 TDD tests covering valid create, null input, and length violations
- Update ProductSearchRequest to use AttributeKey/AttributeValue for query string binding
- Update IProductRepository and IProductsService to return ProductResponse
- Implement ProductRepository.SearchAsync with SqlServerQueryProvider dynamic WHERE clause
- Add EXISTS subquery for attribute filtering to prevent duplicate rows
- Add IN subquery for category filtering across multiple category IDs
- Load product attributes per result and map to ProductResponse
- Add SplitCsv helper to convert stored comma-separated strings back to arrays
- Add MapToResponse helper to decouple DB model from API contract
- Add AddInventoryRequest, InventoryCountRequest, and InventoryTransaction models
- Add IInventoryRepository and IInventoryService interfaces
- Implement InventoryService with validation for quantity, product ID, and transaction ID
- Implement InventoryRepository with transactional insert, delete, and dynamic count query
- Add EXISTS subquery for attribute-based inventory counting across multiple products
- Use ISNULL(SUM(...), 0) to guard against NULL on empty transaction sets
- Add InventoryController with POST, DELETE, and GET count endpoints
- Return 204 No Content on DELETE per REST conventions
- Register IInventoryRepository and IInventoryService in DI as scoped
- Add 8 TDD tests covering validation and delegation for all three operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant