Files
FrontOffice/src/FrontOffice.Main/Utilities/NetworkMembershipDtos.cs
T
masoodafar-web 307302e33d
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 6m9s
feat(organization-chart): enhance organization chart with leg totals and styling improvements
- Updated the organization chart to include gold and silver leg totals for better visibility of user metrics.
- Modified the CSS for the chart to improve layout and styling, ensuring a more user-friendly interface.
- Adjusted JavaScript to dynamically display leg scores, enhancing the overall interactivity of the chart.

These changes improve the clarity and usability of the organization chart, providing users with essential metrics at a glance.
2026-08-25 22:39:30 +03:30

156 lines
5.2 KiB
C#

namespace FrontOffice.Main.Utilities;
/// <summary>
/// DTO for Network Tree node
/// </summary>
public class NetworkNodeDto
{
public long UserId { get; set; }
public string FullName { get; set; } = string.Empty;
public string Mobile { get; set; } = string.Empty;
public string? Avatar { get; set; }
public string Position { get; set; } = string.Empty; // "Root", "Left" or "Right"
public NetworkNodeDto? LeftChild { get; set; }
public NetworkNodeDto? RightChild { get; set; }
public int Level { get; set; }
public bool IsActive { get; set; } = true;
public DateTime? JoinedAt { get; set; }
public bool IsClubActive { get; set; }
public string? ActivationWeekNumber { get; set; }
/// <summary>
/// کد معرف کاربر
/// </summary>
public string? ReferralCode { get; set; }
/// <summary>
/// نام پکیج موثر (مثلاً پکیج طلایی / نقره‌ای)
/// </summary>
public string? PackageName { get; set; }
/// <summary>آخرین امتیاز پای چپ پکیج طلایی</summary>
public int GoldLeftLegTotal { get; set; }
/// <summary>آخرین امتیاز پای راست پکیج طلایی</summary>
public int GoldRightLegTotal { get; set; }
/// <summary>آخرین امتیاز پای چپ پکیج نقره‌ای</summary>
public int SilverLeftLegTotal { get; set; }
/// <summary>آخرین امتیاز پای راست پکیج نقره‌ای</summary>
public int SilverRightLegTotal { get; set; }
}
/// <summary>
/// DTO for flat node structure (for d3-org-chart)
/// </summary>
public class FlatNetworkNodeDto
{
public string Id { get; set; } = string.Empty;
public string ParentId { get; set; } = string.Empty;
public string FullName { get; set; } = string.Empty;
public string Mobile { get; set; } = string.Empty;
public string? Avatar { get; set; }
public string Position { get; set; } = string.Empty;
public int Level { get; set; }
public bool IsActive { get; set; } = true;
public bool IsClubActive { get; set; }
public string? ActivationWeekNumber { get; set; }
public DateTime? JoinedAt { get; set; }
/// <summary>
/// کد معرف کاربر - فقط برای کاربران فعال در باشگاه نمایش داده شود
/// </summary>
public string? ReferralCode { get; set; }
/// <summary>
/// نام پکیج موثر (مثلاً پکیج طلایی / نقره‌ای)
/// </summary>
public string? PackageName { get; set; }
public int GoldLeftLegTotal { get; set; }
public int GoldRightLegTotal { get; set; }
public int SilverLeftLegTotal { get; set; }
public int SilverRightLegTotal { get; set; }
}
/// <summary>
/// DTO for Network Tree response
/// </summary>
public class NetworkTreeDto
{
public NetworkNodeDto? RootNode { get; set; }
public int TotalMembers { get; set; }
public int CurrentDepth { get; set; }
/// <summary>
/// Convert hierarchical tree to flat array for d3-org-chart
/// </summary>
public List<FlatNetworkNodeDto> ToFlatArray()
{
var result = new List<FlatNetworkNodeDto>();
if (RootNode == null) return result;
TraverseAndFlatten(RootNode, "", result);
return result;
}
private void TraverseAndFlatten(NetworkNodeDto node, string parentId, List<FlatNetworkNodeDto> result)
{
var flatNode = new FlatNetworkNodeDto
{
Id = node.UserId.ToString(),
ParentId = parentId,
FullName = node.FullName,
Mobile = node.Mobile,
Avatar = node.Avatar,
Position = node.Position,
Level = node.Level,
IsActive = node.IsActive,
IsClubActive = node.IsClubActive,
ActivationWeekNumber = node.ActivationWeekNumber,
JoinedAt = node.JoinedAt,
ReferralCode = node.ReferralCode,
PackageName = node.PackageName,
GoldLeftLegTotal = node.GoldLeftLegTotal,
GoldRightLegTotal = node.GoldRightLegTotal,
SilverLeftLegTotal = node.SilverLeftLegTotal,
SilverRightLegTotal = node.SilverRightLegTotal
};
result.Add(flatNode);
if (node.LeftChild != null)
{
TraverseAndFlatten(node.LeftChild, flatNode.Id, result);
}
if (node.RightChild != null)
{
TraverseAndFlatten(node.RightChild, flatNode.Id, result);
}
}
}
/// <summary>
/// DTO for Last Member info
/// </summary>
public class LastMemberDto
{
public long UserId { get; set; }
public string FullName { get; set; } = string.Empty;
public string Position { get; set; } = string.Empty;
public DateTime JoinedAt { get; set; }
}
/// <summary>
/// DTO for Network Statistics
/// </summary>
public class NetworkStatisticsDto
{
public int LeftLegCount { get; set; }
public int RightLegCount { get; set; }
public int TotalMembers { get; set; }
public int TreeDepth { get; set; }
public string WeakerLeg { get; set; } = string.Empty; // "Left" or "Right"
public LastMemberDto? LastMember { get; set; }
}