Exemplo n.º 1
0
        public List <ContactGuid> RetrieveAllContactGuid()
        {
            CRMConnect conn = new CRMConnect();

            string fetch2 = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                    <entity name='contact'>
                                        <attribute name='fullname' />
                                        <attribute name='contactid' />
                                        <attribute name='kp_kalimatainsurance' />
                                        <filter type='and'>
                                            <condition attribute='kp_kalimatainsurance' operator='eq' value='4' />
                                        </filter>
                                    </entity>
                            </fetch>";

            EntityCollection dataAll = conn.service.RetrieveMultiple(new FetchExpression(fetch2));

            List <ContactGuid> listOfContacts = new List <ContactGuid>();

            foreach (Entity user in dataAll.Entities)
            {
                ContactGuid contactguid = new ContactGuid();

                contactguid.fullname  = user.Attributes["fullname"].ToString();
                contactguid.contactid = user.Id;

                listOfContacts.Add(contactguid);
            }

            return(listOfContacts);
        }
Exemplo n.º 2
0
        public void PolicyCreation(PolicyCreationModel policyCreationModel)
        {
            CRMConnect conn = new CRMConnect();

            Entity pol = new Entity("kp_policy");

            //string policy = policyCreationModel.kp_policyholder.ToString();
            EntityReference policyholder        = new EntityReference("contact", policyCreationModel.kp_policyholder);
            EntityReference preferredCurrencyID = new EntityReference("contact", policyCreationModel.transactioncurrencyid);


            pol.Attributes.Add("kp_policyholder", policyholder);
            pol.Attributes.Add("transactioncurrencyid", preferredCurrencyID);

            Guid   createdPolicy = conn.service.Create(pol);
            Entity newPolicy     = conn.service.Retrieve("kp_policy", createdPolicy, new ColumnSet(true));

            newPolicy.Attributes.Add("kp_policy", policyCreationModel.kp_policy);

            if (policyCreationModel.kp_collision)
            {
                // newPolicy.Attributes.Add("kp_collision", policyCreationModel.kp_collision);
                newPolicy.Attributes["kp_collision"] = policyCreationModel.kp_collision;
            }
            if (policyCreationModel.kp_comprehensive)
            {
                //newPolicy.Attributes.Add("kp_comprehensive", policyCreationModel.kp_comprehensive);
                newPolicy.Attributes["kp_comprehensive"] = policyCreationModel.kp_comprehensive;
            }
            if (policyCreationModel.kp_liability)
            {
                //newPolicy.Attributes.Add("kp_liability", policyCreationModel.kp_liability);
                newPolicy.Attributes["kp_liability"] = policyCreationModel.kp_liability;
            }
            if (policyCreationModel.kp_protected)
            {
                //newPolicy.Attributes.Add("kp_protected", policyCreationModel.kp_protected);
                newPolicy.Attributes["kp_protected"] = policyCreationModel.kp_protected;
            }
            if (policyCreationModel.kp_uninsured)
            {
                //newPolicy.Attributes.Add("kp_uninsured", policyCreationModel.kp_uninsured);
                newPolicy.Attributes["kp_uninsured"] = policyCreationModel.kp_uninsured;
            }

            conn.service.Update(newPolicy);
        }
Exemplo n.º 3
0
        public Contact RetrieveContact(Guid guid)
        {
            // B6F1EFEE-09A4-E911-A990-000D3A40543B

            // New Connection Made
            CRMConnect conn = new CRMConnect();

            // Fetch Expression for contact
            string fetch2 = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                        <entity name='contact'>
                                        <attribute name='fullname' />
                                        <attribute name='contactid' />
                                        <attribute name='transactioncurrencyid' />
                                        <attribute name='address1_country' />
                                        <order attribute='fullname' descending='false' />
                                        <filter type='and'>
                                            <condition attribute='fullname' operator='not-null' />
                                            <condition attribute='address1_country' operator='not-null' />
                                            <condition attribute='transactioncurrencyid' operator='not-null' />
                                            <condition attribute='contactid' operator='eq' uiname='Dea Tacita' uitype='contact' value='{" + guid + @"}' />
                                        </filter>
                                    </entity>
                                </fetch>";

            EntityCollection dataAll = conn.service.RetrieveMultiple(new FetchExpression(fetch2));

            // Usable format
            Contact contact = new Contact();

            foreach (Entity user in dataAll.Entities)
            {
                contact.fullname         = user.Attributes["fullname"].ToString();
                contact.address1_country = user.Attributes["address1_country"].ToString();

                string currencyID = ((EntityReference)user.Attributes["transactioncurrencyid"]).Id.ToString();
                if (currencyID == "6f14ded1-1ca2-e911-a9aa-000d3a4025c7")
                {
                    contact.transactioncurrencyid = "CAD";
                }
                else if (currencyID == "391b1ea8-0fa2-e911-a9b6-000d3a402766")
                {
                    contact.transactioncurrencyid = "USD";
                }
            }
            return(contact);
        }
Exemplo n.º 4
0
        public void ClaimCreate(ClaimCreationModel kp_claim)
        {
            Entity record = new Entity("kp_claim");

            record.Attributes.Add("kp_claim", kp_claim.kp_claim);

            EntityReference contactReference = new EntityReference("contact", kp_claim.kp_claimcontact);

            record.Attributes.Add("kp_claimcontact", contactReference);

            // Convert to entity reference
            EntityReference policyReference = new EntityReference("kp_policy", kp_claim.kp_claimpolicy);

            record.Attributes.Add("kp_claimpolicy", policyReference);

            CRMConnect conn = new CRMConnect();

            conn.service.Create(record);
        }
        public List <PolicyReferenceModel> PolicyRetrieval(Guid contactguid)
        {
            CRMConnect conn = new CRMConnect();

            string fetch2 = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                <entity name='kp_policy'>
                                    <attribute name='kp_policy' />
                                    <attribute name='kp_policynumber' />
                                    <attribute name='kp_policyholder' />
                                    <attribute name='kp_policyid' />
                                    <order attribute='kp_policy' descending='false' />
                                    <filter type='and'>
                                        <condition attribute='kp_policyholder' operator='eq' uiname='Dīs Pater' uitype='contact' value='{" + contactguid + @"}' />
                                        <condition attribute='kp_policyid' operator='not-null' />
                                        <condition attribute='kp_policy' operator='not-null' />
                                    </filter>
                                </entity>
                            </fetch>";

            EntityCollection dataAll = conn.service.RetrieveMultiple(new FetchExpression(fetch2));

            List <PolicyReferenceModel> listOfPolicies = new List <PolicyReferenceModel>();

            foreach (Entity dataSingle in dataAll.Entities)
            {
                PolicyReferenceModel dataModel = new PolicyReferenceModel();

                dataModel.kp_policy       = dataSingle.Attributes["kp_policy"].ToString();
                dataModel.kp_policynumber = dataSingle.Attributes["kp_policynumber"].ToString();
                dataModel.kp_policyholder = new Guid(((EntityReference)dataSingle.Attributes["kp_policyholder"]).Id.ToString());
                dataModel.kp_policyid     = dataSingle.Id;

                listOfPolicies.Add(dataModel);
            }
            return(listOfPolicies);
        }