Beispiel #1
0
 /// <summary>
 /// 前端导购分类
 /// </summary>
 /// <returns></returns>
 public IActionResult GuidePdtCatgForm(SysUser user, GuideProductCatg entity = null, string imgmsg = null)
 {
     if (NHttpContext.Current.Request.IsAjaxRequest())
     {
         //获取状态
         StateCode state = ServiceIoc.Get <GuideProductCatgService>().Save(user.id, entity, imgmsg);
         return(Json(GetResult(state)));
     }
     else
     {
         //所属分类
         List <GuideProductCatg> Parents = ServiceIoc.Get <GuideProductCatgService>().GetTrees("", HttpUtility.HtmlDecode("&nbsp;&nbsp;"));
         Parents.Insert(0, new GuideProductCatg()
         {
             name = "根", id = 0
         });
         ViewBag.Parents = Parents;
         //当前商品分类
         entity = ServiceIoc.Get <GuideProductCatgService>().GetById(bid);
         if (entity != null)
         {
             ViewBag.entity = JsonConvert.SerializeObject(entity);
         }
     }
     return(View());
 }
Beispiel #2
0
        /// <summary>
        /// 保存广告图
        /// </summary>
        /// <param name="user"></param>
        /// <param name="adimg"></param>
        /// <param name="imgmsg"></param>
        /// <returns></returns>
        public IActionResult BannerForm(SysUser user, Banner entity, string imgmsg)
        {
            if (NHttpContext.Current.Request.IsAjaxRequest())
            {
                StateCode code = ServiceIoc.Get <BannerService>().Save(user.id, entity, imgmsg);
                return(Json(GetResult(code)));
            }
            else
            {
                //所属分类
                List <ProductCatg> productCgtys = ServiceIoc.Get <ProductCatgService>().GetTrees("", HttpUtility.HtmlDecode("&nbsp;&nbsp;"));
                productCgtys.Insert(0, new ProductCatg()
                {
                    name = "——商品分类——", id = 0
                });
                ViewBag.productCgtys = productCgtys;

                //上传票据
                ViewBag.Ticket = StringHelper.GetEncryption(ImgType.Banner + "#" + bid);
                //缺省图片路
                ViewBag.defurl = ResXmlConfig.Instance.DefaultImgSrc(AppGlobal.Res, ImgType.Banner);
                ViewBag.imgurl = ViewBag.defurl;

                entity = ServiceIoc.Get <BannerService>().GetById(bid);
                if (entity != null)
                {
                    ViewBag.entity = JsonConvert.SerializeObject(entity);

                    Img img = ServiceIoc.Get <ImgService>().GetImg(ImgType.Banner, entity.id);
                    if (img != null)
                    {
                        ViewBag.imgurl = string.IsNullOrEmpty(img.getImgUrl()) ? ViewBag.defimgurl : img.getImgUrl();
                    }

                    //商品详情
                    if (entity.content_type == (int)BannerLink.ProductDetails && !string.IsNullOrEmpty(entity.content_value))
                    {
                        long pid = 0;
                        long.TryParse(entity.content_value, out pid);
                        Product product = ServiceIoc.Get <ProductService>().GetById(pid);
                        if (product != null)
                        {
                            ViewBag.bizEntity = JsonConvert.SerializeObject(product);
                        }
                    }//商品列表
                    else if (entity.content_type == (int)BannerLink.ProductList && !string.IsNullOrEmpty(entity.content_value))
                    {
                        GuideProductCatg guideProductCgty = ServiceIoc.Get <GuideProductCatgService>().GetById(long.Parse(entity.content_value));
                        if (guideProductCgty != null)
                        {
                            ViewBag.bizEntity = JsonConvert.SerializeObject(guideProductCgty);
                        }
                    }
                }
            }

            return(View());
        }