private void SetStateStatus(ref ServiceObject so)
        {
            SourceCode.SmartObjects.Services.ServiceSDK.Objects.Method meth = so.Methods[0];
            WizardFunctions helper = new WizardFunctions();

            CRMState state = new CRMState();

            state.Config = crmconfig;

            try
            {
                state.Entity   = NotNull(so.Properties["Entity"].Value);
                state.EntityId = NotNull(so.Properties["EntityId"].Value);
                state.State    = int.Parse(NotNull(so.Properties["State"].Value));
                state.Status   = int.Parse(NotNull(so.Properties["Status"].Value));

                RestResponse <CRMState> response = helper.SetStateStatus(state, config);

                so.Properties.InitResultTable();

                for (int c = 0; c < meth.ReturnProperties.Count; c += 1)
                {
                    Property prop = so.Properties[meth.ReturnProperties[c]];
                    prop = SetStateStatusProperties(prop, response);
                }

                so.Properties.BindPropertiesToResultTable();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        private Property SetGetEntitiesProperties(Property prop, CRMState task)
        {
            if (task != null)
            {
                switch (prop.Name.ToLower())
                {
                case "entity":
                    prop.Value = task.Entity;
                    break;

                case "entityid":
                    prop.Value = task.EntityId;
                    break;

                case "state":
                    prop.Value = task.State;
                    break;

                case "status":
                    prop.Value = task.Status;
                    break;
                }
            }
            return(prop);
        }
        public RestResponse<CRMState> SetStateStatus(CRMState crmState, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Credentials = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource = "K2CRM/CRMSetStateStatus";

            request.AddBody(crmState);

            RestResponse<CRMState> response = client.Execute<CRMState>(request);

            return response;
        }
        public RestResponse <CRMState> SetStateStatus(CRMState crmState, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();

            request.Method        = Method.POST;
            request.Credentials   = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = "K2CRM/CRMSetStateStatus";

            request.AddBody(crmState);

            RestResponse <CRMState> response = client.Execute <CRMState>(request);

            return(response);
        }