Ejemplo n.º 1
0
        public int CreateStore(int parentID, RqApiStore store)
        {
            var client  = new RestClient($"https://entitymanagerdemo.iqmetrix.net/v1/Companies({CompanyID})/Tree/Nodes({parentID})/Locations");
            var request = new RestRequest(Method.POST);

            request.AddHeader("Authorization", $"Bearer {_token.access_token}");
            request.AddHeader("Accept", "application/json");
            request.AddHeader("Content-Type", "application/json");
            request.AddParameter("application/json", JsonConvert.SerializeObject(store), ParameterType.RequestBody);

            var result = client.Execute <RqApiStore>(request);

            return(result.Data.Id);
        }
Ejemplo n.º 2
0
        public void UpdateStore(int parentID, RqApiStore store)
        {
            var oldStore = GetStore(store.Id);

            store.Version = oldStore.Version; //This is required by the API, the version number is incremented every time the store is updated.
            var client  = new RestClient($"https://entitymanagerdemo.iqmetrix.net/v1/Companies({CompanyID})/Tree/Nodes({parentID})/Locations({store.Id})");
            var request = new RestRequest(Method.PUT);

            request.AddHeader("Authorization", $"Bearer {_token.access_token}");
            request.AddHeader("Accept", "application/json");
            request.AddHeader("Content-Type", "application/json");

            request.AddParameter("application/json", JsonConvert.SerializeObject(store), ParameterType.RequestBody);

            var result = client.Execute <RqApiStore>(request);
        }