public async Task <IEnumerable <ServicerDTO> > GetNearbyServicers(double longitude, double latitude, int pageIndex, int pageSize, string key, string category, string subCategory, string appId = "GOOIOS001") { var services = new List <ServicerDTO>(); var skipCount = (pageIndex - 1) * pageSize; var result = _servicerRepository.GetPaged(pageIndex, pageSize, o => (o.Name == key || string.IsNullOrEmpty(key)) && (o.Category == category || string.IsNullOrEmpty(category)) && (o.SubCategory == subCategory || string.IsNullOrEmpty(subCategory)) && (string.IsNullOrEmpty(appId) || o.ApplicationId == appId), o => GetDistance(longitude, latitude, o.Longitude, o.Latitude), true); foreach (var o in result) { o.ResolveAddress(); var servicerImgs = _servicerImageRepository.GetFiltered(g => g.ServicerId == o.Id).ToList(); var ids = servicerImgs.Select(i => i.ImageId).ToList(); var imgs = await _imageServiceProxy.GetImagesByIds(ids); var organization = await _organizationServiceProxy.GetOrganizationById(o.OrganizationId); var logoImgUrl = ""; if (organization != null) { var logoImg = await _imageServiceProxy.GetImageById(organization.LogoImageId); logoImgUrl = logoImg?.HttpPath; } var portrailImageUrl = ""; var portrailImage = await _imageServiceProxy.GetImageById(o.PortraitImageId); if (portrailImage != null) { portrailImageUrl = portrailImage.HttpPath; } services.Add(new ServicerDTO { Category = o.Category, Id = o.Id, PersonalIntroduction = o.PersonalIntroduction, OrganizationId = o.OrganizationId, Address = o.Address, BirthDay = o.BirthDay, Gender = o.Gender, IsSuspend = o.IsSuspend, SubCategory = o.SubCategory, JobNumber = o.JobNumber, Images = imgs?.Select(img => new ServicerImageDTO { Description = img.Description, HttpPath = img.HttpPath, ImageId = img.Id, ServicerId = o.Id, Title = img.Title }), PortraitImageId = o.PortraitImageId, PortraitImageUrl = portrailImageUrl, Name = o.Name, SincerityGoldRate = o.SincerityGoldRate, StartRelevantWorkTime = o.StartRelevantWorkTime, TechnicalGrade = o.TechnicalGrade, TechnicalTitle = o.TechnicalTitle, SincerityGold = o.SincerityGold, ApplicationId = o.ApplicationId }); } return(services); }