public object GetTopicDetail(long id) { TopicModel model = new TopicModel(); TopicInfo topic = ServiceProvider.Instance <ITopicService> .Create.GetTopicInfo(id); model.Id = topic.Id; model.Name = topic.Name; //model.TopImage = "http://" + Url.Request.RequestUri.Host + topic.TopImage; model.TopImage = Core.HimallIO.GetRomoteImagePath(topic.TopImage); model.TopicModule = new List <TopicModuleModel>(); var topicModule = topic.TopicModuleInfo.ToList(); foreach (var module in topicModule) { var topicModuleModel = new TopicModuleModel(); var productIds = module.ModuleProductInfo .Where(item => item.ProductInfo.SaleStatus == ProductInfo.ProductSaleStatus.OnSale && item.ProductInfo.AuditStatus == ProductInfo.ProductAuditStatus.Audited) .OrderBy(item => item.Id) //.Skip(pageSize * (pageNo - 1)) //.Take(pageSize) .Select(item => item.ProductId); var products = ServiceProvider.Instance <IProductService> .Create.GetProductByIds(productIds); var model1 = products.ToArray().Select(item => new TopicModuleProductModel { Name = item.ProductName, Id = item.Id, //Image = "http://" + Url.Request.RequestUri.Host + item.GetImage(Model.ProductInfo.ImageSize.Size_350), Image = Core.HimallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_350), Price = item.MinSalePrice, MarketPrice = item.MarketPrice }); topicModuleModel.Id = module.Id; topicModuleModel.Name = module.Name; topicModuleModel.TopicModelProduct = model1.ToList(); model.TopicModule.Add(topicModuleModel); } return(Json(new { Success = "true", Topic = model })); }
public object GetTopicDetail(long id) { var topic = TopicApplication.GetTopic(id); var modules = TopicApplication.GetModules(id); var allModuleProducts = TopicApplication.GetModuleProducts(modules.Select(p => p.Id)); var allOnSaleProducts = ProductManagerApplication.GetOnSaleProducts(allModuleProducts.Select(p => p.ProductId).ToList()); TopicModel model = new TopicModel(); model.Id = topic.Id; model.Name = topic.Name; model.TopImage = HimallIO.GetRomoteImagePath(topic.TopImage); model.TopicModule = new List <TopicModuleModel>(); foreach (var module in modules) { var topicModuleModel = new TopicModuleModel(); var moduleProducts = allModuleProducts.Where(p => p.ModuleId == module.Id); topicModuleModel.Id = module.Id; topicModuleModel.Name = module.Name; topicModuleModel.TopicModelProduct = allOnSaleProducts .Where(p => moduleProducts.Select(x => x.ProductId).Contains(p.Id)) .Select(item => new TopicModuleProductModel { Name = item.ProductName, Id = item.Id, Image = Core.HimallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_350), Price = item.MinSalePrice, MarketPrice = item.MarketPrice }).ToList(); model.TopicModule.Add(topicModuleModel); } dynamic result = SuccessResult(); result.Topic = model; return(result); }