Exemplo n.º 1
0
        public static Entities.Contact Map(FileUploadContact fileContact,
                                           Entities.Contact contact, Guid employerGuid)
        {
            if (contact == null)
            {
                contact    = new Entities.Contact();
                contact.Id = Guid.NewGuid();
            }

            contact.EntityRefId = employerGuid;
            var contactType = GetContactType(fileContact.ContactType);
            var preferredMethodOfContact = GetPreferredMethodOfContact(fileContact.PreferredContact);

            contact.ContactTypeId = (int)contactType;
            contact.PreferredContactMethodType = (int)preferredMethodOfContact;
            //contact.IsPrimary
            contact.FirstName     = fileContact.FirstName;
            contact.MiddleName    = fileContact.MiddleName;
            contact.LastName      = fileContact.LastName;
            contact.JobTitle      = fileContact.JobTitle;
            contact.BusinessPhone = fileContact.PhoneBusiness;
            contact.MobilePhone   = fileContact.PhoneMobile;
            contact.HomePhone     = fileContact.PhoneHome;
            //contact.Email = fileContact.Email;
            contact.CreatedOn  = fileContact.Created;
            contact.ModifiedOn = fileContact.ModifiedOn;

            return(contact);
        }
        public CsvLoadedSuccess()
        {
            var fileReader = new CsvContactFileReader();

            using (var stream = File.Open(DataFilePath, FileMode.Open))
            {
                _loadResult  = fileReader.Load(stream);
                _firstRecord = _loadResult.Data[0];
            }
        }
Exemplo n.º 3
0
        private static FileUploadContact CreateContact(SpreadsheetDocument document, OpenXmlElement row)
        {
            var contact          = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.Contact));
            var checksum         = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.Checksum));
            var modifiedOn       = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.ModifiedOn));
            var companyName      = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.CompanyName));
            var createdOn        = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.CreatedOnCompany));
            var contactType      = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.ContactType));
            var phoneHome        = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.PhoneHome));
            var jobTitle         = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.JobTitle));
            var phoneMobile      = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.PhoneMobile));
            var modifiedBy       = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.ModifiedBy));
            var modified         = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.Modified));
            var preferredContact = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.PreferredContact));
            var fullName         = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.FullName));
            var firstName        = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.FirstName));
            var middleName       = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.MiddleName));
            var lastName         = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.LastName));
            var phoneBusiness    = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.PhoneBusiness));
            var createdBy        = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.CreatedBy));
            var created          = CellValueRetriever.Get(document, row.Descendants <Cell>().ElementAt(ContactColumnIndex.Created));

            var isValid = ValidateMandatory(contact, contactType, preferredContact);

            if (!isValid)
            {
                return(null);
            }

            var fileUploadContact = new FileUploadContact
            {
                Contact          = new Guid(contact),
                Checksum         = checksum,
                ModifiedOn       = modifiedOn.ToDate(),
                CompanyName      = companyName,
                CreatedOnCompany = createdOn.ToDate(),
                ContactType      = contactType,
                PhoneHome        = phoneHome,
                JobTitle         = jobTitle,
                PhoneMobile      = phoneMobile,
                ModifiedBy       = modifiedBy,
                Modified         = modified.ToDate(),
                PreferredContact = preferredContact,
                FullName         = fullName,
                FirstName        = firstName,
                MiddleName       = middleName,
                LastName         = lastName,
                PhoneBusiness    = phoneBusiness,
                CreatedBy        = createdBy,
                Created          = created.ToDate()
            };

            return(fileUploadContact);
        }