Example #1
0
        private void SetupLevels(IAmoCrmEntityConverter converter, ApiResponseRoot <ApiAccountRootResponse> accountResponse)
        {
            var levelsCustomField = accountResponse.Response.Account.CustomFields.LeadFields.FirstOrDefault(f => f.Name == LevelCustomFieldName);

            LevelsMap = new Dictionary <int, Level>();
            if (levelsCustomField != null)
            {
                LevelsMap = converter.Convert <Level>(levelsCustomField).ToDictionary(l => l.AmoId);
            }
        }
Example #2
0
        public AmoCrmImportContext(IAmoDataProvider provider, IAmoCrmEntityConverter converter, bool excludeHistoricalData = true)
        {
            var contactsResponse         = provider.GetContacts();
            var leadsResponse            = provider.GetLeads();
            var contactLeadLinksResponse = provider.GetContactLeadLinks();
            var accountResponse          = provider.GetAccount();

            ContactsMap = contactsResponse.Response.Entities.Select(converter.Convert).ToDictionaryByFirstOccurence(c => c.AmoId);
            var leads = leadsResponse.Response.Entities.Select(converter.Convert);

            UsersMap = accountResponse.Response.Account.Users.Select(converter.Convert).ToDictionaryByFirstOccurence(c => c.AmoId);

            LeadContactsMap = BuildLeadContactLinks(contactLeadLinksResponse.Response.Entities);

            SetupLevels(converter, accountResponse);
            SetupLeadStatuses(converter, accountResponse);

            if (excludeHistoricalData)
            {
                leads = leads.Where(l => !IsHistorical(l));
            }

            LeadsMap = leads.ToDictionaryByFirstOccurence(c => c.AmoId);
        }
Example #3
0
 public AmoCrmImportManager(IAmoDataProvider amoDataProvider, IAttendanceUow attendanceUow, IAmoCrmEntityConverter entityConverter)
 {
     this.amoDataProvider = amoDataProvider;
     this.attendanceUow   = attendanceUow;
     this.entityConverter = entityConverter;
 }
Example #4
0
 private void SetupLeadStatuses(IAmoCrmEntityConverter converter, ApiResponseRoot <ApiAccountRootResponse> accountResponse)
 {
     LeadStatusMap = accountResponse.Response.Account.LeadStatuses.Select(converter.Convert).ToDictionary(c => c.AmoId);
 }