private async Task <IMap> LoadMap(long mapId) { MapDto map = _mapService.GetById(mapId); if (map is null) { return(null); } IEnumerable <MapNpcDto> npcs = await _npcService.GetByMapIdAsync(mapId); IEnumerable <MapMonsterDto> monsters = await _monsterService.GetByMapIdAsync(mapId); IEnumerable <PortalDto> portals = await _portalService.GetByMapIdAsync(mapId); IEnumerable <ShopDto> shops = await _shopService.GetByMapNpcIdsAsync(npcs.Select(s => s.Id)); List <long> npcMonsterIds = npcs.Select(s => s.NpcMonsterId).Intersect(monsters.Select(s => s.NpcMonsterId)).ToList(); IEnumerable <NpcMonsterSkillDto> skills = await _npcMonsterSkillService.GetByNpcMonsterIdsAsync(npcMonsterIds); return(new SimpleMap(map, monsters, npcs, portals, shops, skills)); }