コード例 #1
0
        private static bool AddSocialContactUpdates(this FWTIndividualUpdate update, FWTIndividual individual, Customer customer)
        {
            var newSocialContacts = new List <SocialContact>();

            if (customer.SocialContacts != null && individual.SocialContacts == null)
            {
                newSocialContacts = customer.SocialContacts.ToList();
            }

            if (customer.SocialContacts != null && individual.SocialContacts != null)
            {
                newSocialContacts = customer.SocialContacts.Where(_ => !individual.SocialContacts.Any(x => x.SocialID == _.Value)).ToList();
            }

            if (individual.SocialContacts != null && newSocialContacts.Count > 0)
            {
                var socialContacts      = CreateSocialContacts(newSocialContacts.ToArray());
                var socialContactUpdate = new FWTSocialContactUpdate[newSocialContacts.Count];


                for (int i = 0; i < socialContacts.Length; i++)
                {
                    socialContactUpdate[i] = new FWTSocialContactUpdate {
                        SocialContacts = socialContacts[i], ListItemUpdateType = "Insert"
                    };
                    return(true);
                }

                update.SocialContacts = socialContactUpdate;
            }

            return(false);
        }
コード例 #2
0
        private static bool AddPhoneUpdates(this FWTIndividualUpdate update, FWTIndividual individual, Customer customer)
        {
            if (individual.RequiresPhoneUpdate(customer))
            {
                var newPhone = new FWTContactPhone {
                    Number = customer.Telephone, Preferred = true, DeviceType = "unknown"
                };
                update.ContactPhones = new[] { new FWTContactPhoneUpdate {
                                                   PhoneDetails = newPhone, ListItemUpdateType = "Insert"
                                               } };
                return(true);
            }

            if ((!string.IsNullOrWhiteSpace(customer.Telephone) && individual.ContactPhones != null) &&
                (individual.ContactPhones.Where(x => x.Number.Replace(" ", "").Replace("-", "").Equals(customer.Telephone.Replace(" ", "").Replace("-", "")) && x.Preferred == false).Count() > 0))
            {
                var updatePhone = individual.ContactPhones.FirstOrDefault(x => x.Number.Replace(" ", "").Replace("-", "").Equals(customer.Telephone.Replace(" ", "").Replace("-", "")));
                if (updatePhone != null)
                {
                    updatePhone.Preferred = true;
                    update.ContactPhones  = new[] { new FWTContactPhoneUpdate {
                                                        PhoneDetails = updatePhone, ListItemUpdateType = "Update"
                                                    } };
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        private static bool AddEmailUpdates(this FWTIndividualUpdate update, FWTIndividual individual, Customer customer)
        {
            if (string.IsNullOrWhiteSpace(customer.Email))
            {
                return(false);
            }

            if (individual.RequiresNewEmailUpdate(customer))
            {
                update.ContactEmails = new[] { new FWTContactEmailUpdate {
                                                   EmailDetails = new FWTContactEmail {
                                                       EmailAddress = customer.Email, Preferred = true
                                                   }, ListItemUpdateType = "Insert"
                                               } };
                return(true);
            }
            else if (individual.RequiresPreferredEmailUpdate(customer))
            {
                var email = individual.ContactEmails.First(x => x.EmailAddress.Trim().ToUpper() == customer.Email.Trim().ToUpper());
                email.Preferred      = true;
                update.ContactEmails = new[] { new FWTContactEmailUpdate {
                                                   EmailDetails = email, ListItemUpdateType = "Update"
                                               } };
                return(true);
            }

            return(false);
        }
コード例 #4
0
        private static bool AddAddressUpdates(this FWTIndividualUpdate update, FWTIndividual individual, Customer customer)
        {
            if (customer.Address == null)
            {
                return(false);
            }

            if (individual.RequiresAddressUpdate(customer))
            {
                var newContactPostal = new FWTContactPostal();
                newContactPostal.Preferred = true;
                if (!string.IsNullOrEmpty(customer.Address.UPRN))
                {
                    newContactPostal.Option = new [] { VerintConstants.UseUprnForAddress, VerintConstants.IgnoreInvalidUprn };
                    newContactPostal.UPRN   = customer.Address.UPRN.Trim();
                }
                else
                {
                    newContactPostal.AddressNumber = customer.Address.Number;
                    newContactPostal.AddressLine   = new[] { customer.Address.AddressLine1, customer.Address.AddressLine2, customer.Address.AddressLine3, customer.Address.City };
                    newContactPostal.City          = customer.Address.City;
                    newContactPostal.Postcode      = customer.Address.Postcode;
                }

                update.ContactPostals = new[] { new FWTContactPostalUpdate {
                                                    PostalDetails = newContactPostal, ListItemUpdateType = "Insert"
                                                } };
                return(true);
            }
            else if (!string.IsNullOrWhiteSpace(customer.Address.UPRN) && individual.ContactPostals != null)
            {
                var preferredContact = individual.ContactPostals.FirstOrDefault(x => x.Preferred);

                if (preferredContact != null)
                {
                    if (string.IsNullOrEmpty(preferredContact.UPRN))
                    {
                        return(false);
                    }

                    if (customer.Address.UPRN.Trim() != preferredContact.UPRN.Trim())
                    {
                        var contactPostal = individual.ContactPostals.Where(_ => _.UPRN != null).FirstOrDefault(_ => _.UPRN.Trim() == customer.Address.UPRN.Trim());
                        if (contactPostal != null)
                        {
                            contactPostal.Preferred = true;
                            update.ContactPostals   = new[] { new FWTContactPostalUpdate {
                                                                  PostalDetails = contactPostal, ListItemUpdateType = "Update"
                                                              } };
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #5
0
        public static bool AddAnyRequiredUpdates(this FWTIndividualUpdate update, FWTIndividual individual, Customer customer)
        {
            var nameUpdate    = update.AddNameUpdates(individual, customer);
            var addressUpdate = update.AddAddressUpdates(individual, customer);
            var emailUpdate   = update.AddEmailUpdates(individual, customer);
            var phoneUpdate   = update.AddPhoneUpdates(individual, customer);
            var socialUpdate  = update.AddSocialContactUpdates(individual, customer);
            var dobUpdate     = update.AddDateOfBirth(individual, customer);

            return(nameUpdate || addressUpdate || emailUpdate || phoneUpdate || socialUpdate || dobUpdate);
        }
コード例 #6
0
        public async Task UpdateIndividual(FWTIndividual individual, Customer customer)
        {
            var update = new FWTIndividualUpdate
            {
                BriefDetails = individual.BriefDetails
            };

            var requiresUpdate = update.AddAnyRequiredUpdates(individual, customer);

            if (requiresUpdate)
            {
                await _verintConnection.updateIndividualAsync(update);
            }
        }
コード例 #7
0
        private static bool AddDateOfBirth(this FWTIndividualUpdate update, FWTIndividual individual, Customer customer)
        {
            if (customer.DateOfBirth != null && customer.DateOfBirth != DateTime.MinValue && !individual.DateOfBirthSpecified)
            {
                update.DateOfBirthUpdate = new FWTDateOfBirthUpdate
                {
                    DateOfBirth          = customer.DateOfBirth,
                    DateOfBirthSpecified = true,
                    UpdateType           = "Insert"
                };

                return(true);
            }

            return(false);
        }
コード例 #8
0
        private static bool AddNameUpdates(this FWTIndividualUpdate update, FWTIndividual individual, Customer customer)
        {
            if (!string.IsNullOrWhiteSpace(customer.Surname) && individual.Name == null)
            {
                var newName = new FWTIndividualName
                {
                    Forename = new[] { customer.Forename + string.Empty },
                    Surname  = customer.Surname + string.Empty,
                    Initials = customer.Initials + string.Empty,
                    Title    = customer.Title + string.Empty,
                };

                update.Name = new[] { new FWTIndividualNameUpdate {
                                          IndividualNameDetails = newName, ListItemUpdateType = "Insert"
                                      } };
                return(true);
            }

            return(false);
        }