Example #1
0
        private static List<PhoneInfo> FillPhonCollection(IDataReader reader, out int totalRecords)
        {
            var retVal = new List<PhoneInfo>();
            totalRecords = 0;
            try
            {
                while (reader.Read())
                {
                    //fill business object
                    var info = new PhoneInfo();
                    /*

                    info.PhoneId = ConvertHelper.ToInt32(reader["PhoneId"]);

                    info.ContactId = ConvertHelper.ToInt32(reader["ContactId"]);

                    info.PhoneType = ConvertHelper.ToString(reader["PhoneType"]);

                    info.PhoneNumber = ConvertHelper.ToString(reader["PhoneNumber"]);

                    info.IsPrimary = ConvertHelper.ToInt32(reader["IsPrimary"]);

                    */
                    retVal.Add(info);
                }
                //Get the next result (containing the total)
                reader.NextResult();

                //Get the total no of records from the second result
                if (reader.Read())
                {
                    totalRecords = Convert.ToInt32(reader[0]);
                }

            }
            catch (Exception exc)
            {
                //DotNetNuke.Services.Exceptions.Exceptions.LogException(exc);
            }
            finally
            {
                //close datareader
                ObjectHelper.CloseDataReader(reader, true);
            }
            return retVal;
        }
Example #2
0
 private static void UpdatePhone(int contactId, List<string> mobiles)
 {
     if (mobiles.IsNullOrEmpty()) return;
     var listPhones = PhoneRepository.GetByContact(contactId) ?? new List<PhoneInfo>();
     foreach (var mobile in mobiles
         .Where(c => !c.IsStringNullOrEmpty())
         .Where(c => !listPhones.Exists(p => p.PhoneNumber.Equals(c))))
     {
         if (!listPhones.Exists(c => c.PhoneType.ToInt32() == (int)PhoneType.HomePhone))
         {
             var phone = new PhoneInfo
                             {
                                 IsPrimary = 0,
                                 PhoneNumber = mobile,
                                 ContactId = contactId,
                                 PhoneType = ((int)PhoneType.HomePhone).ToString(),
                             };
             PhoneRepository.Create(phone);
             listPhones.Add(phone);
         }
         if (!listPhones.Exists(c => c.PhoneType.ToInt32() == (int)PhoneType.MobilePhone))
         {
             var phone = new PhoneInfo
             {
                 IsPrimary = 0,
                 PhoneNumber = mobile,
                 ContactId = contactId,
                 PhoneType = ((int)PhoneType.MobilePhone).ToString(),
             };
             PhoneRepository.Create(phone);
             listPhones.Add(phone);
         }
         if (!listPhones.Exists(c => c.PhoneType.ToInt32() == (int)PhoneType.Tel))
         {
             var phone = new PhoneInfo
             {
                 IsPrimary = 0,
                 PhoneNumber = mobile,
                 ContactId = contactId,
                 PhoneType = ((int)PhoneType.Tel).ToString(),
             };
             PhoneRepository.Create(phone);
             listPhones.Add(phone);
         }
     }
 }
Example #3
0
 public static void Update(PhoneInfo info)
 {
     DataProvider.Instance().Phones_Update(info.ContactId, info.PhoneType, info.PhoneNumber,info.IsPrimary);
 }