Beispiel #1
0
        public List<ContactCsvLine> SearchCsv(ContactSearch search)
        {
            if (!search.HasCriteria())
                return new List<ContactCsvLine>();

            var contacts = SearchContacts(search)
               .Select(c => new ContactCsvLine
               {
                   Id = c.id,
                   FirstName = c.firstname,
                   LastName = c.lastname,
                   AddressLine1 = c.is_primary ? c.addressline1 : c.addressline1_alt,
                   AddressLine2 = c.is_primary ? c.addressline2 : c.addressline2_alt,
                   State = c.is_primary ? c.state : c.state_alt,
                   Zip = c.is_primary ? c.zip : c.zip_alt,
                   Country = c.is_primary ? c.country : c.country_alt,
                   Title = c.is_primary ? c.title : c.title_alt,
                   City = c.is_primary ? c.city : c.city_alt,
                   Organization = c.is_primary ? c.organization : c.organization_alt,
                   SubNumber = c.is_subscriber ? c.sub_number : null,
                   PrimaryEmail = c.email1,
                   AltEmail = c.email2
               }).ToList();

            foreach (var c in contacts)
            {
                c.SubscriberNumber = c.SubNumber.HasValue ? c.SubNumber.Value.ToString() : "";
                List<string> titlesToFollowUp = dbContext.shipments.Where(x => x.contact_id == c.Id && x.should_followup).Select(s =>  s.shipment_title.title1).ToList();

                if(titlesToFollowUp.Count > 0)
                    c.TitlesForFollowUp = string.Join(", ", titlesToFollowUp.ToArray());
            }
            return contacts;
        }
Beispiel #2
0
        /// <summary>
        /// TODO: DONT FORGET SEARCH CSV!
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public IEnumerable<ContactDetails> Search(ContactSearch search)
        {
            if (!search.HasCriteria())
                return new List<ContactDetails>();

            return SearchContacts(search)
               .Select(s => new ContactDetails
               {
                   City = s.is_primary ? s.city : s.city_alt,
                   DisplayName = s.lastname + ", " + s.firstname,
                   Organization = s.is_primary ? s.organization : s.organization_alt,
                   Id = s.id
               });
        }