Exemple #1
0
        public Flag GetFlag(string id)
        {
            Flag result = null;
            var sectionsElement = _document.GetElement("Flags", "");
            var element = sectionsElement.Elements("Flag")
                .SingleOrDefault(x => x.GetElement("Id","").GetValue() == id);
            if(element != null)
                result = new Flag() { Id = element.GetElement("Id","").GetValue(), Name = element.GetElement("Name","").GetValue() };
            return result;

        }
Exemple #2
0
        private static ConversionResult ConvertRowsToContacts(IEnumerable<DataRow> rawRows, IEnumerable<FieldMap> fieldMaps, Category category, Flag flag)
        {
            int successCount = 0, failureCount = 0, duplicateCount = 0;

            var contacts = new List<AllClientsContact>();
            foreach (var rawRow in rawRows)
            {
                var contact = new AllClientsContact();
                contact.FirstName = GetFieldMapValue(rawRow, fieldMaps, "FirstName");
                contact.LastName = GetFieldMapValue(rawRow, fieldMaps, "LastName");
                contact.City = GetFieldMapValue(rawRow, fieldMaps, "City");
                contact.State = GetFieldMapValue(rawRow, fieldMaps, "State");
                contact.Zip = GetFieldMapValue(rawRow, fieldMaps, "Zip");
                contact.Email = GetFieldMapValue(rawRow, fieldMaps, "Email");
                contact.Company = GetFieldMapValue(rawRow, fieldMaps, "Company");
                contact.Phone = GetFieldMapValue(rawRow, fieldMaps, "Phone");
                contact.Categories.Add(category);

                contact.Custom = new List<CustomElement>();
                var birthDate = new CustomElement { Name = "Birthday", Value = GetFieldMapValue(rawRow, fieldMaps, "Birthday") };
                contact.Custom.Add(birthDate);
                contact.Flags.Add(flag);

                if (!contact.IsValid())
                {
                    failureCount++;
                    continue;
                }
                if (contacts.Where(x => x.Email == contact.Email).Count() != 0)
                {
                    duplicateCount++;
                    continue;
                }
                successCount++;
                contacts.Add(contact);
            }
            return new ConversionResult { SuccessCount = successCount, FailureCount = failureCount, DuplicateCount = duplicateCount, Contacts = contacts };
        }