Esempio n. 1
0
        /// <summary>
        /// 一键保存产品列表
        /// </summary>
        public void SaveGoodsList()
        {
            string data_save = GetString("data_save");

            if (string.IsNullOrEmpty(data_save))
            {
                ReturnErrorMsg("没有选择需要保存的商品");
                return;
            }

            var json = new JavaScriptSerializer();
            var list = json.Deserialize(data_save, typeof(List <ChangeGoods>)) as List <ChangeGoods>;

            if (list == null)
            {
                ReturnErrorMsg("没有选择需要保存的商品");
                return;
            }

            var saveList = new List <Goods>();

            foreach (var changeGoodse in list)
            {
                var goods = GoodsHelper.GetGoods(changeGoodse.Id);
                if (goods == null || goods.SellerId != CurSellerId)
                {
                    ReturnErrorMsg("没有权限修改产品或者产品不存在");
                    return;
                }
                goods.Nowprice      = changeGoodse.Nowprice;
                goods.OriginalPrice = changeGoodse.OriginalPrice;
                //goods.IsRecommend = changeGoodse.IsRecommend;
                goods.IsHot = changeGoodse.IsHot;

                saveList.Add(goods);
            }
            if (saveList.Count > 0)
            {
                if (GoodsHelper.SaveGoodsList(saveList))
                {
                    ReturnCorrectMsg("保存成功");
                    return;
                }
            }
            ReturnCorrectMsg("保存失败");
        }