Refactor and enhance entity mapping, repositories, and value objects#68
Merged
samuelzedec merged 13 commits intomainfrom Aug 25, 2025
Merged
Refactor and enhance entity mapping, repositories, and value objects#68samuelzedec merged 13 commits intomainfrom
samuelzedec merged 13 commits intomainfrom
Conversation
…port - Added `IInvitationRepository` to handle invitation entity persistence and lifecycle operations. - Updated `IUserRepository` and `ICompanyRepository` with enhanced descriptions for better clarity. - Extended `IUnitOfWork` to include support for `IInvitationRepository`. - Updated dependency injection to register `IInvitationRepository`.
- Introduced `BaseEntityConfiguration` to standardize common entity configurations. - Added extension methods for configuring reusable properties (e.g., TaxId, Email, Phone, FullName, CompanyName). - Refactored `UserMap`, `InvitationMap`, and `CompanyMap` to inherit from `BaseEntityConfiguration` and utilize the extension methods. - Enhanced maintainability and reduced code duplication across entity mappings.
…stants - Introduced error messages for `Discount` (e.g., invalid percentage or fixed amount, greater than subtotal). - Added `Money` error messages for handling negative values and invalid operations (summing or subtracting different currencies). - Included a new error message for quantity validation. WIP
…lidation - Added `Money` value object to encapsulate monetary values and their operations. - Supported operations include addition, subtraction, and multiplication with validation for currency consistency and negative values. - Implemented exception handling for invalid operations (`InvalidMoneyException`, `InvalidSumException`, `InvalidSubtractionException`). - Created comprehensive unit tests for `Money` ensuring behavior correctness. - Added `IHasUnitPrice` interface for entities with unit price.
…ation - Introduced `Quantity` value object to encapsulate quantities and related operations. - Supported operations include addition, subtraction, and multiplication with validation against zero and negative values. - Added factory methods for predefined quantities (`One`, `Zero`). - Implemented `InvalidQuantityException` for handling invalid operations. - Created `IHasQuantity` interface for objects requiring associated quantities. - Added comprehensive unit tests to validate `Quantity` behavior and error scenarios.
- Introduced `Discount` value object to encapsulate percentage or fixed amount discounts with optional reasons. - Added validation for invalid percentages and fixed amounts. - Implemented `CalculateDiscount`, `HasDiscount`, `IsPercentage`, and `IsFixedAmount` utility methods. - Created exceptions for invalid operations (`InvalidPercentageException`, `InvalidFixedAmountException`). - Added `IHasDiscount` interface for entities requiring associated discounts. - Developed comprehensive unit tests to ensure correctness of `Discount` operations and edge cases.
…port - Implemented `IHasCompanyName`, `IHasTaxId`, `IHasEmail`, and `IHasPhone` interfaces in `Company` entity. - Enhanced modularity and reusability of `Company` properties.
- Introduced `Invitation` entity with properties, methods, and `IHasEmail` and `IAggregateRoot` interfaces. - Added `IInvitationRepository` and `InvitationRepository` for invitation persistence and lifecycle operations. - Developed comprehensive unit tests for `Invitation` entity covering creation, permissions, status changes, and edge cases.
…oken` interface - Introduced `RandomToken` value object to generate cryptographically secure, Base64-encoded random tokens. - Implemented factory method `Create` for token creation. - Added `IHasRandomToken` interface for entities requiring associated tokens. - Developed comprehensive unit tests to validate token uniqueness, security, and behavior.
…iscount`, `UnitPrice`, and `Quantity` - Introduced new extension methods to standardize configuration for `RandomToken`, `Discount`, `UnitPrice`, and `Quantity`. - Enhanced consistency and reusability across entity mappings. wip
- Migrated `Invitation` entity to use the new `RandomToken` value object for improved encapsulation and reusability. - Updated `InvitationMap` to leverage standardized `ConfigureRandomToken` method for token configuration. - Refactored unit tests to accommodate changes and verify `RandomToken` behavior. - Removed legacy `GeneratePublicCode` method and associated properties.
- Added migrations for `Product`, `ProductCategory`, `Order`, and `OrderItem` entities. - Introduced relationships, indexes, and constraints to support the product catalog and order management. - Removed obsolete `CompanyIsNullException` as it is no longer required.
- Eliminated the `ToString` method from `Money` due to lack of usage and redundancy. - Removed `ToString_WhenCalledWithFormat_ShouldReturnFormattedValue` test case in alignment with the method removal. - Adjusted unit tests to reflect changes in `Money.Create` parameters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RandomToken,Discount,Money, andQuantityvalue objects with corresponding validation, utility methods, and unit tests to improve encapsulation and reusability.Invitationentity and repository with lifecycle operations and unit tests.Companyentity with new interfaces (IHasCompanyName,IHasTaxId, etc.).BaseEntityConfigurationand reusable extension methods.UnitOfWorksupport forInvitation.