예제 #1
0
        public void ClientAttributeTest()
        {
            var attrib = new ClientAttribute();

            Assert.IsTrue(attrib.error);

            attrib.error = false;

            Assert.IsFalse(attrib.error);
        }
        public ClientAttribute Build(DataTable clientAtrributeTabel)
        {
            ClientAttribute clientAttribute = null;
            var             reader          = new DataRowReader(clientAtrributeTabel.Rows);

            if (reader.Read())
            {
                clientAttribute = new ClientAttribute(reader.ToDecimal("NFAdminFee"),
                                                      reader.ToDecimal("AdminFee1"),
                                                      reader.ToDecimal("FactorFee1"),
                                                      reader.ToDecimal("RetentPercent")
                                                      );
            }
            return(clientAttribute);
        }
예제 #3
0
        public static Boolean addorupdateClientFromXero(Contact xcontact)
        {
            // is the xero id already present
            int ucrmclientid = UNMSHelper.getclientbyxeroid(xcontact.Id.ToString());

            webapi.Models.ClientContactWritable        newunmscontact;
            List <webapi.Models.ClientContactWritable> newlistcontacts = new List <webapi.Models.ClientContactWritable>();

            if ((xcontact.EmailAddress != "") || (xcontact.Phones.Any(_ => _.PhoneNumber != "")))
            {
                newunmscontact = new webapi.Models.ClientContactWritable()
                {
                    Phone     = xcontact.Phones.First().PhoneAreaCode + xcontact.Phones.First().PhoneNumber,
                    Email     = xcontact.EmailAddress,
                    IsBilling = true,
                    IsContact = true
                };
                newlistcontacts.Add(newunmscontact);
            }

            if (xcontact.Phones.Any(_ => _.PhoneNumber != ""))
            {
                newunmscontact = new ClientContactWritable()
                {
                    Phone = xcontact.Phones[3].PhoneAreaCode + xcontact.Phones[3].PhoneNumber
                };
                newlistcontacts.Add(newunmscontact);
            }

            var newUcrmAttribute = new ClientAttribute()
            {
                CustomAttributeId = 1,
                Value             = xcontact.Id.ToString()
            };
            List <ClientAttribute> newlistattributes = new List <ClientAttribute>();

            newlistattributes.Add(newUcrmAttribute);

            string templastname;
            string tempfirstname;
            bool   tempLead = false;

            if (xcontact.IsCustomer == false)
            {
                tempLead = true;
            }
            if ((xcontact.FirstName == null) && (xcontact.LastName == null))
            {
                tempfirstname = null;
                templastname  = xcontact.Name;
            }
            else
            {
                tempfirstname = xcontact.FirstName;
                templastname  = xcontact.LastName;
            }

            var newunmsclient = new ClientWritable()
            {
                OrganizationId = 1,
                IsLead         = tempLead,
                FirstName      = tempfirstname,
                LastName       = templastname,
                UserIdent      = "",
                Street1        = xcontact.Addresses[1].AddressLine1,
                Street2        = xcontact.Addresses[1].AddressLine2,
                City           = xcontact.Addresses[1].City,
                ZipCode        = xcontact.Addresses[1].PostalCode,
                Attributes     = newlistattributes,
                Contacts       = newlistcontacts,
                InvoiceAddressSameAsContact = true,
                Username            = xcontact.EmailAddress,
                InvoiceMaturityDays = null,
                RegistrationDate    = "2019-09-01T00:00:00+0100"
            };

            if (ucrmclientid == 0)
            {
                var uc = HTTPHelper.httpPost("clients", newunmsclient);
            }
            else
            {
                var uc = HTTPHelper.httpPatch("clients/" + ucrmclientid, newunmsclient);
            }


            return(true);
        }
        public BatchSchedule Build(DataTable batchTable, BatchScheduleFinanceInfo batchScheduleFinanceInfo, ClientAttribute clientAttribute)
        {
            BatchSchedule batchSchedule = null;
            var           reader        = new DataRowReader(batchTable.Rows);

            if (reader.Read())
            {
                batchSchedule = new BatchSchedule(reader.ToInteger("BatchNumber"),
                                                  reader.ToString("txtStatus"),
                                                  reader.ToShort("Status"),
                                                  reader.ToNullableDate("BatchDate"),
                                                  reader.ToNullableDate("Released"),
                                                  reader.ToNullableDate("Modified"),
                                                  reader.ToNullableDate("DtFinished"),
                                                  reader.ToString("Header"),
                                                  reader.ToString("BNotes"),
                                                  reader.ToString("CreatedBy"),
                                                  reader.ToString("ModifiedBy"), batchScheduleFinanceInfo, clientAttribute);
            }
            return(batchSchedule);
        }
예제 #5
0
        public static string updateorcreatexerocontact(ClientReadOnly UClient, string clientxeroid)
        {
            XeroCoreApi xeroapp = getxeroapp();
            Contact     contact = new Contact();

            if (clientxeroid != "")
            {
                contact = getXeroContact(clientxeroid);
            }

            if (UClient.CompanyName != "")
            {
                contact.Name      = UClient.CompanyName;
                contact.FirstName = UClient.CompanyContactFirstName;
                contact.LastName  = UClient.CompanyContactLastName;
            }
            else
            {
                contact.Name      = UClient.FirstName + " " + UClient.LastName;
                contact.FirstName = UClient.FirstName;
                contact.LastName  = UClient.LastName;
            }


            List <Phone> phonesl = new List <Phone>();

            if (UClient.Contacts.FirstOrDefault().Phone != null)
            {
                Phone phn1 = new Phone();
                phn1.PhoneType   = Xero.Api.Core.Model.Types.PhoneType.Mobile;
                phn1.PhoneNumber = UClient.Contacts.FirstOrDefault().Phone;
                phonesl.Add(phn1);
            }

            contact.Phones = phonesl;
            List <Address> addl = new List <Address>();

            Address add = new Address();

            add.AddressType  = Xero.Api.Core.Model.Types.AddressType.PostOfficeBox;
            add.AddressLine1 = UClient.Street1;
            add.AddressLine2 = UClient.Street2;
            add.City         = UClient.City;
            add.PostalCode   = UClient.ZipCode;

            addl.Add(add);
            contact.Addresses    = addl;
            contact.EmailAddress = UClient.Contacts.FirstOrDefault().Email;
            Xero.Api.Core.Model.Contact contactreturned = xeroapp.Update(contact);
            // now update the crm with the xeroid
            if (clientxeroid == "")
            {
                UnmsClient      UXClient         = new UnmsClient();
                ClientAttribute newUcrmAttribute = new ClientAttribute()
                {
                    CustomAttributeId = 1,
                    Value             = contactreturned.Id.ToString()
                };
                List <ClientAttribute> newlistattributes = new List <ClientAttribute>();
                newlistattributes.Add(newUcrmAttribute);
                UXClient.attributes = newlistattributes;

                HTTPHelper.httpPatch("clients" + "/" + UClient.Id, UXClient);
            }
            return(contactreturned.Id.ToString());
        }
        public void ClientDefaultsToError()
        {
            var attrib = new ClientAttribute();

            Assert.IsTrue(attrib.error);
        }