Esempio n. 1
0
        public object Do_GetGoods(object param)
        {
            GetGoodsParam ggp = JsonConvert.DeserializeObject <GetGoodsParam>(param.ToString());

            if (ggp == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }
            GoodsDao  gd = new GoodsDao();
            DataTable dt = gd.getGoods(ggp.barcode);

            if (dt.Rows.Count > 0)
            {
                Goods goods = new Goods();
                goods.id        = dt.Rows[0]["id"].ToString();
                goods.slt       = dt.Rows[0]["thumb"].ToString().Split(',');
                goods.goodsname = dt.Rows[0]["goodsname"].ToString();
                goods.price     = dt.Rows[0]["price"].ToString();
                goods.stock     = dt.Rows[0]["stock"].ToString();
                return(goods);
            }
            else
            {
                throw new ApiException(CodeMessage.GoodsNotFound, "GoodsNotFound");
            }
        }