/// <summary>
 /// Check if one of phone number from checkWith collection exist in Sage's phoneNumbers collection
 /// </summary>
 public static bool ContainsOneOf(this PhoneNumberCollection phoneNumbers, List <PhoneNumber> checkWith)
 {
     if (phoneNumbers == null || checkWith == null)
     {
         return(false);
     }
     return(checkWith.Any(phoneNumber => phoneNumbers.Any(p => p.Number == phoneNumber.Number)));
 }
        public void ConstructorWithInitialCollectionAddsToList()
        {
            var initial = new PhoneNumberCollection {
                new PhoneNumber(), new PhoneNumber()
            };
            var phoneNumberCollection = new PhoneNumberCollection(initial);

            Assert.Equal(2, phoneNumberCollection.Count);
        }
Exemple #3
0
 public void InsertAndRemove()
 {
     Assert.DoesNotThrow(delegate
     {
         PhoneNumber phoneNumber = new PhoneNumber();
         PhoneNumberCollection phoneNumberCollection = new PhoneNumberCollection();
         phoneNumberCollection.Add(phoneNumber);
         phoneNumber = phoneNumberCollection[0];
         phoneNumberCollection[0] = phoneNumber;
         phoneNumberCollection.Remove(phoneNumber);
     });
 }
 public ConstituentInfo(DataSet tessResults)
 {
     DataTableCollection tables = tessResults.Tables;
     if (tables.Contains("Addresses") && tables["Addresses"].Rows.Count > 0)
     {
         Addresses = new AddressCollection(tables["Addresses"]);
     }
     if (tables.Contains("ConstituentAttribute")
             && tables["ConstituentAttribute"].Rows.Count > 0)
     {
         Attributes = new ConstituentAttributeCollection(tables["ConstituentAttribute"]);
     }
     if (tables.Contains("EmailAddresses") && tables["EmailAddresses"].Rows.Count > 0)
     {
         EmailAddresses = new EmailAddressCollection(tables["EmailAddresses"]);
     }
     if (tables.Contains("Associations") && tables["Associations"].Rows.Count > 0)
     {
         Associations = new AssociationCollection(tables["Associations"]);
     }
     if (tables.Contains("Constituency") && tables["Constituency"].Rows.Count > 0)
     {
         Constituencies = new ConstituencyCollection(tables["Constituency"]);
     }
     if (tables.Contains("ConstituentHeader") && tables["ConstituentHeader"].Rows.Count > 0)
     {
         Header = new ConstituentHeader(tables["ConstituentHeader"]);
     }
     if (tables.Contains("Contribution") && tables["Contribution"].Rows.Count > 0)
     {
         Contributions = new ContributionRecordCollection(tables["Contribution"]);
     }
     if (tables.Contains("Interests") && tables["Interests"].Rows.Count > 0)
     {
         Interests = new InterestCollection(tables["Interests"]);
     }
     if (tables.Contains("Memberships") && tables["Memberships"].Rows.Count > 0)
     {
         Memberships = new MembershipCollection(tables["Memberships"]);
     }
     if (tables.Contains("Phones") && tables["Phones"].Rows.Count > 0)
     {
         PhoneNumbers = new PhoneNumberCollection(tables["Phones"]);
     }
     if (tables.Contains("ProgramListings") && tables["ProgramListings"].Rows.Count > 0)
     {
         ProgramListings = new ProgramListingCollection(tables["ProgramListings"]);
     }
     if (tables.Contains("Rankings") && tables["Rankings"].Rows.Count > 0)
     {
         Rankings = new RankCollection(tables["Rankings"]);
     }
 }
Exemple #5
0
        public void InsertAndRemoveNonExistentIndices()
        {
            PhoneNumberCollection phoneNumberCollection = new PhoneNumberCollection();

            Assert.Throws <IndexOutOfRangeException>(delegate
            {
                var phoneNumber_ = phoneNumberCollection[0];
            });
            var phoneNumber = new PhoneNumber();

            Assert.Throws <IndexOutOfRangeException>(delegate
            {
                phoneNumberCollection[0] = phoneNumber;
            });
        }
Exemple #6
0
 public static void PopulateFromModel(this PhoneNumberCollection sagePhoneNumberCollection, List <Models.Data.PhoneNumber> contactPhoneNumbers)
 {
     if (contactPhoneNumbers == null)
     {
         return;
     }
     foreach (var contactPhoneNumber in contactPhoneNumbers)
     {
         var phoneKind = contactPhoneNumber.Key.ToEnum <PhoneNumberKind>();
         var contact   = sagePhoneNumberCollection.SingleOrDefault(c => c.Key == phoneKind);
         if (contact != null)
         {
             contact.Number = contactPhoneNumber.Number;
         }
     }
 }
Exemple #7
0
        public static String GetPhoneNumber(PhoneNumberCollection numberCollection, bool preferredNumber)
        {
            if (numberCollection == null)
            {
                return(String.Empty);
            }

            String phoneNumber = String.Empty;

            foreach (var item in numberCollection)
            {
                if (item.Preferred == preferredNumber)
                {
                    phoneNumber = item.Number;
                }
            }
            return(phoneNumber);
        }
Exemple #8
0
        /// <summary>
        /// Gets the phone numbers from the details array
        /// </summary>
        /// <returns>A <see cref="PhoneNumberCollection"/></returns>
        private static PhoneNumberCollection ParseTelephoneNumbers()
        {
            PhoneNumberCollection phoneNumberCollection = new PhoneNumberCollection();

            var telStrings = _contactDetails.Where(s => s.StartsWith("TEL"));

            foreach (string telString in telStrings)
            {
                string phoneString = telString.Replace("TEL;", "").Replace("TEL:", "");
                //Remove multiple typing
                if (phoneString.Contains(";"))
                {
                    int index = phoneString.LastIndexOf(";");
                    phoneString = phoneString.Remove(0, index + 1);
                }

                //Logic
                if (phoneString.StartsWith("CELL"))
                {
                    phoneString = phoneString.Replace(";VOICE", "");
                    phoneString = phoneString.Replace("CELL:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Cell
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("HOME"))
                {
                    phoneString = phoneString.Replace(";VOICE", "");
                    phoneString = phoneString.Replace("HOME:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Home
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("WORK"))
                {
                    phoneString = phoneString.Replace(";VOICE", "");
                    phoneString = phoneString.Replace("WORK:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Work
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("VOICE:"))
                {
                    phoneString = phoneString.Replace("VOICE:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Voice
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("FAX"))
                {
                    phoneString = phoneString.Replace("FAX:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Fax
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("TEXTPHONE"))
                {
                    phoneString = phoneString.Replace("TEXTPHONE:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Fax
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("TEXT"))
                {
                    phoneString = phoneString.Replace("TEXT:", "");
                    PhoneNumber phoneNumber = new PhoneNumber();
                    phoneNumber.Number = phoneString;
                    phoneNumber.Type   = PhoneNumberType.Text;
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("VIDEO"))
                {
                    phoneString = phoneString.Replace("VIDEO:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Video
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("PAGER"))
                {
                    phoneString = phoneString.Replace("PAGER:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Pager
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("MAIN-NUMBER"))
                {
                    phoneString = phoneString.Replace("MAIN-NUMBER:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Fax
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("BBS"))
                {
                    phoneString = phoneString.Replace("BBS:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Pager
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("CAR"))
                {
                    phoneString = phoneString.Replace("CAR:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Pager
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("MODEM"))
                {
                    phoneString = phoneString.Replace("MODEM:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Pager
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else if (phoneString.StartsWith("ISDN"))
                {
                    phoneString = phoneString.Replace("ISDN:", "");
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.Pager
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
                else
                {
                    PhoneNumber phoneNumber = new PhoneNumber
                    {
                        Number = phoneString,
                        Type   = PhoneNumberType.None
                    };
                    phoneNumberCollection.Add(phoneNumber);
                }
            }
            return(phoneNumberCollection);
        }