public async Task <UnitWithSpecificationModel[]> GetUnitsByGroupIdAsync(int groupId) { UnitWithSpecificationModel[] units = (await _unitFacade.GetUnitsByGroupIdAsync <UnitDTO>(groupId)) .Select(Utils.Convert).ToArray(); return(units); }
public async Task <IActionResult> MyUnits(int unitGroupID) { Log.Called(nameof(MyUnits), $"groupID={unitGroupID}"); var units = new List <UnitFullDTO>(); var currentGroup = new UnitGroupNameDto(); var groups = await _ugFacade.GetUnitGroupsByUserIdAsync <UnitGroupNameDto>(UserInfoManager.UserId); if (unitGroupID != 0) { currentGroup = await _ugFacade.GetUnitGroupByIdAsync <UnitGroupNameDto>(unitGroupID); units = await _unitFacade.GetUnitsByGroupIdAsync <UnitFullDTO>(unitGroupID); } else { // User did not select UG, but has some if (groups.Any()) { currentGroup = groups.First(); units = await _unitFacade.GetUnitsByGroupIdAsync <UnitFullDTO>(currentGroup.Id); } } var dto = new UnitsOverviewDTO { UserId = UserInfoManager.UserId, Groups = groups, CurrentGroup = currentGroup, UnitsInGroup = units }; Log.Info($"DTO: UID={dto.UserId}, curr_group={currentGroup.Name}, units={units.Count}"); return(View(dto)); }