C
C#2y ago
SWEETPONY

✅ How to group nested departments?

First of all I wanna show structure of departments: FIRST OFFICE | first room | second room | third room ( nested of second room ) SECOND OFFICE | first room | second room | third room ( nested of second room ) okey, each office and each room has id, title and parent_id for example, third_room will have parent_id == second room.id if parent_id == null, this is root! so I have following code:
var nestedDepartments = ( await _departmentClient
.GetByParentsIds( _parameters.DepartmentIDs )
.Unwrap() );
var nestedDepartments = ( await _departmentClient
.GetByParentsIds( _parameters.DepartmentIDs )
.Unwrap() );
it will return all departments with id, parent_id but without any grouping and I don't understand how to group I have GetByParentId function so I can write this:
List<(string, IList<DepartmentDto>)> departments = new();
foreach ( var id in _parameters.DepartmentIDs )
{
var department = await _departmentClient
.GetByParentId( id )
.Unwrap();

departments.Add( (id, department) );
}
List<(string, IList<DepartmentDto>)> departments = new();
foreach ( var id in _parameters.DepartmentIDs )
{
var department = await _departmentClient
.GetByParentId( id )
.Unwrap();

departments.Add( (id, department) );
}
So I need the same but with GetByParentsIds function
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server