private Property SetChangeOwnerProperties(Property prop, CRMEntityOwnership task)
        {
            if (task != null)
            {
                switch (prop.Name.ToLower())
                {
                case "assignee":
                    prop.Value = task.Assignee;
                    break;

                case "assigneeid":
                    prop.Value = task.AssigneeId;
                    break;

                case "target":
                    prop.Value = task.Target;
                    break;

                case "targetId":
                    prop.Value = task.TargetId;
                    break;
                }
            }
            return(prop);
        }
        private void ChangeOwner(ref ServiceObject so)
        {
            SourceCode.SmartObjects.Services.ServiceSDK.Objects.Method meth = so.Methods[0];

            CRMEntityOwnership owner = new CRMEntityOwnership();

            owner.Config = crmconfig;

            try
            {
                owner.Assignee   = NotNull(so.Properties["Assignee"].Value);
                owner.AssigneeId = NotNull(so.Properties["AssigneeId"].Value);
                owner.Target     = NotNull(so.Properties["Target"].Value);
                owner.TargetId   = NotNull(so.Properties["TargetId"].Value);

                CRMEntityOwnership response = CRMFunctions.CRMChangeOwner(owner);

                so.Properties.InitResultTable();

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

                so.Properties.BindPropertiesToResultTable();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public RestResponse<CRMEntityOwnership> ChangeOwner(CRMEntityOwnership crmEntityOwnership, 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/CRMChangeOwner";

            request.AddBody(crmEntityOwnership);

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

            return response;
        }
Пример #4
0
        public RestResponse <CRMEntityOwnership> ChangeOwner(CRMEntityOwnership crmEntityOwnership, 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/CRMChangeOwner";

            request.AddBody(crmEntityOwnership);

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

            return(response);
        }