Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bugs for User #33

Merged
merged 3 commits into from
Jun 21, 2024
Merged

Fixed bugs for User #33

merged 3 commits into from
Jun 21, 2024

Conversation

phamtiendungcw
Copy link
Owner

PR Classification

This pull request implements new features and code cleanup by introducing the CQRS pattern, enhancing DTO mappings, and improving security practices.

PR Summary

This PR focuses on restructuring the application to support the CQRS pattern, enhancing security by modifying DTOs, and refining AutoMapper configurations for cleaner separation of concerns.

  • Introduced MediatR in UserController.cs for CQRS pattern implementation and CRUD operations.
  • Removed PasswordHash property from UpdateUserDto.cs and adjusted UserDtoValidator.cs for improved security.
  • Corrected logical error in DeleteUserCommandHandler.cs by changing CreateAsync to DeleteAsync.
  • Simplified and corrected AutoMapper configurations in various mapping profiles to ensure accurate DTO to domain entity mappings.
  • Removed unnecessary logging dependencies from CreateArticleCommandHandler.cs to focus on core functionalities.

PR Classification

This pull request implements significant architectural enhancements, focusing on API controller refinement, DTO validation and mapping improvements, and aligning the application with CQRS and clean architecture principles through MediatR utilization.

PR Summary

The pull request introduces a new UserController with CRUD operations following the CQRS pattern, improves DTO mappings, and fixes a critical bug in user deletion. It also streamlines the application's structure by cleaning up project references and modifying command and query classes for direct instantiation.

  • UserController.cs: Added with CRUD operations, utilizing MediatR for queries and commands.
  • Command and Query Classes: Transitioned from abstract to public to facilitate direct instantiation with MediatR handlers.
  • Mapping Profiles: Revised mappings across various profiles to ensure correct DTO to domain entity mappings.
  • DeleteUserCommandHandler.cs: Corrected the deletion logic by replacing CreateAsync with DeleteAsync.
  • UpdateUserDto.cs & UserDtoValidator.cs: Enhanced security by removing PasswordHash property and its validation.

- Introduced `UserController` with CRUD operations using MediatR for clean separation of concerns and streamlined handling of user-related actions.
- Removed unused `Controllers` folder reference from `MLS.Api.csproj` for project cleanup.
- Converted all command and query classes from `abstract` to `concrete` to simplify usage and align with CQRS and Mediator patterns.
- Enhanced logging in `CreateArticleCommandHandler.cs` for clearer context in validation errors.
- Standardized namespaces and usings across various files for better code organization.
- Adjusted project references to ensure correct inter-project dependencies, enhancing the solution's architecture.
Reversed the mapping direction from DTOs to entities across various profiles, enhancing data transformation consistency and integrity. Implemented a condition in update mappings to only use non-null source values, preventing data loss. Removed obsolete entity-to-DTO mappings and cleaned up namespaces for better clarity and organization. This comprehensive refactoring improves the application's data handling between layers, ensuring a more consistent and reliable architecture.
- Integrated `IUserRepository` into `UserController` for enhanced direct repository actions, moving beyond the exclusive use of CQRS with MediatR for user operations.
- Updated `UserController.Put` method route to expect user ID in the request body instead of URL.
- Removed `PasswordHash` from `UpdateUserDto` and its validation in `UserDtoValidator` to prevent password updates through this DTO, enhancing security.
- Fixed incorrect method call in `DeleteUserCommandHandler` by replacing `CreateAsync` with `DeleteAsync` for proper user deletion.
- Transitioned `UpdateUserCommand` from abstract to concrete and made `User` property nullable to support partial updates.
- Altered mapping profiles to map all properties regardless of nullability, simplifying data update mechanisms and allowing for potential null value overwrites.
@phamtiendungcw phamtiendungcw merged commit 693db14 into master Jun 21, 2024
1 check passed
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