Skip to content

Implement Materials CRUD and update tests for the Material entity#19

Merged
evans-costa merged 5 commits into
mainfrom
feature/materials-crud
Apr 1, 2026
Merged

Implement Materials CRUD and update tests for the Material entity#19
evans-costa merged 5 commits into
mainfrom
feature/materials-crud

Conversation

@evans-costa

Copy link
Copy Markdown
Owner

This pull request introduces a complete CRUD (Create, Read, Update, Delete) implementation for managing materials in the application, including API endpoints, application commands, queries, handlers, validation, mapping extensions, and corresponding unit tests. The changes ensure that only authenticated users can manage their own materials, with proper validation and error handling throughout the workflow.

API Layer:

  • Added a new MaterialsController with endpoints for registering, retrieving (all/by ID), updating, and deleting materials, all scoped to the authenticated user.

Application Layer:

  • Commands & Handlers:

    • Implemented RegisterMaterialCommand, UpdateMaterialCommand, and DeleteMaterialCommand along with their handlers to support material creation, update, and deletion, ensuring user ownership and proper error handling. [1] [2] [3] [4] [5] [6]
    • Added validators for both register and update commands to enforce required fields and valid values. [1] [2]
  • Queries & Handlers:

    • Added GetMaterialsQuery and GetMaterialByIdQuery with handlers to retrieve all materials for a user or a specific material by ID, returning appropriate errors if not found. [1] [2] [3] [4]
  • Mapping & Response:

    • Introduced mapping extensions to convert between requests, commands, and response DTOs, and defined a MaterialResponse record for API responses. [1] [2]
    • Added request DTOs for registering and updating materials. [1] [2]

Domain Layer:

  • Extended the Material entity with an Update method, including validation for name, price, and unit.

Testing:

  • Added unit tests for the RegisterMaterialCommandHandler and DeleteMaterialCommandHandler, covering both successful and failure scenarios. [1] [2]

@evans-costa evans-costa merged commit 5852da9 into main Apr 1, 2026
3 checks passed
@evans-costa evans-costa deleted the feature/materials-crud branch April 1, 2026 01:41
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