示例#1
0
        /// <summary>
        /// 得到商品详情
        /// </summary>
        /// <returns></returns>
        public virtual IList <GoodsDetailEntity> GetGoodsDetails(GoodsEntity goods)
        {
            var dataEntity = GoodsDetail();
            var infos      = new List <GoodsDetailEntity>();
            var info       = new GoodsDetailEntity
            {
                Detail         = Editor1.TextArea.Value,
                Name           = "Detail",
                Attachment     = upAttchment.GetFileName(),
                AttachmentByte = upAttchment.GetFileByte(),
                Goods          = goods,
                Product        = new ProductEntity {
                    Id = 0
                }
            };

            if (dataEntity != null)
            {
                info.SaveType = SaveType.Modify;
                info.SetProperty(it => it.Detail);
                info.SetProperty(it => it.Attachment);
                info.Id = dataEntity.Id;
            }
            else
            {
                info.SaveType = SaveType.Add;
            }
            infos.Add(info);
            return(infos);
        }
示例#2
0
        /// <summary>
        /// 得到产品图片
        /// </summary>
        protected virtual GoodsDetailEntity GetGoodsDetail(long goodsId, long productId)
        {
            var query = new QueryInfo();

            query.Query <GoodsDetailEntity>()
            .Where(it => (it.Goods.Id == goodsId && it.Product.Id == 0) || it.Product.Id == productId)
            .Select(it => new object[] { it.Detail, it.Name });
            var infos = this.GetEntities <GoodsDetailEntity>(query);
            GoodsDetailEntity info = infos?.FirstOrDefault(it => it.Product != null && it.Product.Id == productId);

            info = info ?? infos.FirstOrDefault();
            return(info);
        }
示例#3
0
        /// <summary>
        /// 填充详情页模板
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="goods"></param>
        /// <param name="sku"></param>
        protected virtual void FillGoodsDetail(DirectoryInfo directory, GoodsEntity goods, string sku)
        {
            if (directory == null || !directory.Exists)
            {
                return;
            }
            goods.GoodsDetails = goods.GoodsDetails ?? new List <GoodsDetailEntity>();
            var product = goods.Products == null ? null : goods.Products.FirstOrDefault(it => it.Sku == sku);

            if (product == null)
            {
                product = new ProductEntity {
                    Id = 0
                }
            }
            ;
            var goodsDetail = new GoodsDetailEntity
            {
                SaveType = SaveType.Add,
                Goods    = goods,
                Product  = product,
                Detail   = GetGoodsDetail(goods, directory),
            };

            goods.GoodsDetails.Add(goodsDetail);
            if (goods.Products == null)
            {
                return;
            }
            var dics = directory.GetDirectories();

            foreach (var dic in dics)
            {
                var tproduct = goods.Products.FirstOrDefault(it => it.Name == dic.Name);
                if (tproduct == null)
                {
                    continue;
                }
                FillGoodsDetail(dic, goods, tproduct.Sku);
            }
        }