public async Task <IEnumerable <ServiceDTO> > GetNearbyServices(double longitude, double latitude, int pageIndex, int pageSize, string key, string category, string subCategory, string appId = "GOOIOS001") { var services = new List <ServiceDTO>(); var skipCount = (pageIndex - 1) * pageSize; var result = _serviceRepository.GetPaged(pageIndex, pageSize, o => (o.Title.Contains(key) || string.IsNullOrEmpty(key)) && (o.Category == category || string.IsNullOrEmpty(category)) && (o.SubCategory == subCategory || string.IsNullOrEmpty(subCategory)) && (o.Status != ServiceStatus.Deleted) && (string.IsNullOrEmpty(appId) || o.ApplicationId == appId) && (o.ServeScope >= (GetDistance(longitude, latitude, o.Longitude, o.Latitude) / 1000) || o.ServeScope == 0), o => GetDistance(longitude, latitude, o.Longitude, o.Latitude), true); foreach (var o in result) { o.ResolveAddress(); var serviceImgs = _serviceImageRepository.GetFiltered(g => g.ServiceId == o.Id)?.ToList() ?? new List <ServiceImage>(); var ids = serviceImgs.Select(i => i.ImageId).ToList(); var imgs = await _imageServiceProxy.GetImagesByIds(ids); var servicePhone = ""; var organization = await _organizationServiceProxy.GetOrganizationById(o.OrganizationId); var logoImgUrl = ""; if (organization != null) { var logoImg = await _imageServiceProxy.GetImageById(organization.LogoImageId); logoImgUrl = logoImg?.HttpPath; servicePhone = organization.CustomServicePhone; } services.Add(new ServiceDTO { Category = o.Category, Id = o.Id, Introduction = o.Introduction, OrganizationId = o.OrganizationId, ServeScope = o.ServeScope, SincerityGold = o.SincerityGold, Station = o.Station, Status = o.Status, SubCategory = o.SubCategory, Title = o.Title, Images = imgs?.Select(img => new ServiceImageDTO { Description = img.Description, HttpPath = img.HttpPath, ImageId = img.Id, ServiceId = o.Id, Title = img.Title }) ?? new List <ServiceImageDTO>(), OrganizationLogoUrl = logoImgUrl, OrganizationName = organization?.ShortName, Distance = ProcessDistance(GetDistance(longitude, latitude, o.Longitude, o.Latitude)), ServicePhone = servicePhone, IsAdvertisement = o.IsAdvertisement, PersonalizedPageUri = o.PersonalizedPageUri, ApplicationId = o.ApplicationId }); } return(services); }
public async Task <IEnumerable <CommentDTO> > GetByServiceId(string serviceId, int pageIndex, int pageSize) { var objs = _commentRepository.GetCommentsByServiceId(serviceId, pageIndex, pageSize); var result = new List <CommentDTO>(); foreach (var item in objs) { var imgIds = _commentImageRepository.GetFiltered(o => o.CommentId == item.Id).Select(g => g.ImageId).ToList(); var userTask = _authServiceProxy.GetUser(item.CreatedBy); var imgs = await _imageServiceProxy.GetImagesByIds(imgIds); var user = await userTask; result.Add(new CommentDTO { Content = item.Content, OrderId = item.OrderId, CommentOwnerUserNickName = user?.NickName, PortraitImageUrl = user?.PortraitUrl, ReservationId = item.ReservationId, ImageIds = imgIds, Images = imgs?.Select(obj => new CommentImageDTO { Title = obj.Title, ImageId = obj.Id, CommentId = item.Id, Description = obj.Description, HttpPath = obj.HttpPath }), CreatedOn = item.CreatedOn.ToString("yyyy-MM-dd") }); } return(result); }
public async Task <GoodsDTO> GetGoods(string id) { var obj = _goodsRepository.Get(id); if (obj != null) { var goodsImages = _goodsImageRepository.GetFiltered(o => o.GoodsId == id).Select(item => new GoodsImageDTO { GoodsId = item.GoodsId, Id = item.Id, ImageId = item.ImageId }).ToList(); var imageIds = goodsImages.Select(o => o.ImageId).ToList(); var images = await _imageServiceProxy.GetImagesByIds(imageIds); foreach (var img in goodsImages) { var pic = images.FirstOrDefault(o => o.Id == img.ImageId); img.HttpPath = pic?.HttpPath; img.Title = pic?.Title; img.Description = pic?.Description; } var grouponCondition = _grouponConditionRepository.GetFiltered(o => o.GoodsId == id).Select(item => new GrouponConditionDTO { Id = item.Id, GoodsId = item.GoodsId, MoreThanNumber = item.MoreThanNumber, Price = item.Price }); return(new GoodsDTO { Category = obj.Category, Description = obj.Description, Detail = obj.Detail, Id = obj.Id, ItemNumber = obj.ItemNumber, MarketPrice = obj.MarketPrice, OptionalPropertyJsonObject = obj.OptionalPropertyJsonObject, Status = obj.Status, Stock = obj.Stock, StoreId = obj.StoreId, SubCategory = obj.SubCategory, Title = obj.Title, Unit = obj.Unit, UnitPrice = obj.UnitPrice, GoodsImages = goodsImages, GrouponConditions = grouponCondition, DistributionScope = obj.DistributionScope }); } return(null); }
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); }