public ApplicationGroup[] Group(ApplicationListItem[] applications, OrderType[] groups, long?clientId = null, long?senderId = null, long?forwarderId = null, long?carrierId = null) { var awbIds = applications.Select(x => x.AirWaybillId ?? 0).Distinct().ToArray(); _airWaybills = _awbRepository.Get(awbIds).ToDictionary(x => x.Id, x => x); _awbAggregates = _awbRepository.GetAggregate(awbIds, clientId, senderId, forwarderId, carrierId) .ToDictionary(x => x.AirWaybillId, x => x); _countWithouAwb = _awbRepository.GetTotalCountWithouAwb(clientId, senderId, forwarderId, carrierId); _weightWithouAwb = _awbRepository.GetTotalWeightWithouAwb(clientId, senderId, forwarderId, carrierId); _docWeightWithouAwb = _awbRepository.GetTotalDocWeightWithouAwb(clientId, senderId, forwarderId, carrierId); _valueWithouAwb = _awbRepository.GetTotalValueWithouAwb(clientId, senderId, forwarderId, carrierId); _volumeWithouAwb = _awbRepository.GetTotalVolumeWithouAwb(clientId, senderId, forwarderId, carrierId); return(GroupImpl(applications, groups)); }