Exemple #1
0
        /// <summary>
        /// 添加推荐商品
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        private string AddGoodsRecommend(string json)
        {
            dynamic obj       = JsonConvert.DeserializeObject <dynamic>(json);
            int     type      = Convert.ToInt32(obj.code);
            int     status    = Convert.ToInt32(obj.status);
            int     articleid = Convert.ToInt32(obj.articleid);
            int     sort      = Convert.ToInt32(obj.sort);

            DAL.GoodsInfoDal goodsInfoDal = new DAL.GoodsInfoDal();
            bool             isExist      = goodsInfoDal.ExistGoodsRecommend(articleid, type);

            if (isExist)
            {
                return(JsonMethod.GetError(3, "此推荐商品已存在"));// "{\"d\":false,\"msg\":\"此推荐商品已存在\"}";
            }
            bool result = goodsInfoDal.AddGoodsRecommend(articleid, type, status, sort);

            return(result ? JsonMethod.GetError(1, "添加成功") : JsonMethod.GetError(0, "添加失败,请稍后重试"));// "{\"d\":true,\"msg\":\"添加成功\"}" : "{\"d\":false,\"msg\":\"系统错误,请稍后重试\"}";
        }
Exemple #2
0
        /// <summary>
        /// 修改推荐商品
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        private string UpdateGoodsRecommend(string json)
        {
            dynamic obj           = JsonConvert.DeserializeObject <dynamic>(json);
            int     articleid     = Convert.ToInt32(obj.articleid);
            int     old_articleid = Convert.ToInt32(obj.old_articleid);
            int     type          = Convert.ToInt32(obj.code);
            int     old_type      = Convert.ToInt32(obj.old_type);
            int     status        = Convert.ToInt32(obj.status);
            int     sort          = Convert.ToInt32(obj.sort);

            DAL.GoodsInfoDal goodsInfoDal = new DAL.GoodsInfoDal();
            if (articleid != old_articleid)
            {
                bool isExist = goodsInfoDal.ExistGoodsRecommend(articleid, type);
                if (isExist)
                {
                    return(JsonMethod.GetError(3, "此推荐商品已存在"));
                }
            }
            bool result = goodsInfoDal.UpdateGoodsRecommend(articleid, old_articleid, type, old_type, status, sort);

            return(result ? JsonMethod.GetError(1, "修改成功") : JsonMethod.GetError(0, "修改失败,请稍后重试"));
        }