Exemple #1
0
        public Model.ProductModel Create(Model.ProductModel model)
        {
            Model.ProductModel objReturn = null;

            string json = JsonConvert.SerializeObject(model);

            string result = base.Post(apiPrefix, json);

            if (!string.IsNullOrEmpty(result))
            {
                var objCreate = JsonConvert.DeserializeObject <Model.CreateProductReturnModel>(result);
                objReturn = objCreate.Product;
            }

            return(objReturn);
        }
Exemple #2
0
        public Model.ProductModel GetById(int Id)
        {
            Model.ProductModel objReturn = null;

            string result = base.Get(apiPrefix);

            if (!string.IsNullOrEmpty(result))
            {
                var objList = JsonConvert.DeserializeObject <List <Model.ProductModel> >(result);
                objReturn = objList.
                            Where(w => w.Id == Id)
                            .FirstOrDefault();
            }

            return(objReturn);
        }