Files
CMS/src/CMSMicroservice.Application/NetworkMembershipCQ/Commands/MoveInNetwork/MoveInNetworkCommand.cs
masoodafar-web db96a02f89 feat: Add NetworkMembershipCQ - Phase 4 Application Layer
- Implemented 3 Commands with handlers and validators:
  * JoinNetworkCommand: Add user to binary network tree
    - Validates parent exists and is in network
    - Validates leg position is empty
    - Records history with NetworkMembershipAction.Join
  * MoveInNetworkCommand: Move user to different position
    - Validates new parent and leg availability
    - Prevents circular dependencies (IsDescendant check)
    - Records old/new parent and leg in history
  * RemoveFromNetworkCommand: Remove user from network
    - Validates no children exist (must move/remove first)
    - Soft delete (sets NetworkParentId to null)
    - Idempotent design

- Implemented 3 Queries with handlers, validators, and DTOs:
  * GetNetworkTreeQuery: Binary tree visualization
    - Recursive tree building with MaxDepth limit (1-10)
    - Returns nested structure with Left/Right children
  * GetUserNetworkPositionQuery: User position details
    - Parent info, leg position, children counts
    - Left/Right child counts for balance view
  * GetNetworkMembershipHistoryQuery: Complete audit trail
    - Filter by UserId, pagination support
    - Shows Join/Move/Remove actions with full details

- All operations include complete history tracking
- Binary tree validation (parent-child relationships)
- Circular dependency prevention in MoveInNetwork
- 21 new files, ~850 lines of code
- Build successful with 0 errors
2025-11-29 04:19:40 +03:30

28 lines
783 B
C#

namespace CMSMicroservice.Application.NetworkMembershipCQ.Commands.MoveInNetwork;
/// <summary>
/// Command برای جابجایی کاربر در شبکه دوتایی
/// </summary>
public record MoveInNetworkCommand : IRequest<Unit>
{
/// <summary>
/// شناسه کاربر که می‌خواهد جابجا شود
/// </summary>
public long UserId { get; init; }
/// <summary>
/// شناسه والد جدید در شبکه
/// </summary>
public long NewParentId { get; init; }
/// <summary>
/// موقعیت جدید در شبکه (Left یا Right)
/// </summary>
public NetworkLeg NewLegPosition { get; init; }
/// <summary>
/// دلیل جابجایی
/// </summary>
public string? Reason { get; init; }
}