private static async Task <List <ConstantContactModel> > Create(List <string> ccLists) { List <ConstantContactModel> model = new List <ConstantContactModel>(); IEnumerable <ContactList> allLists = await ConstantContact.GetAllLists(); foreach (string ccList in ccLists) { ContactList existingList = IdentifyList(ccList); // found in constant contact ? if (existingList == null) { // no create it !! var newList = new ContactList { Name = ccList, Status = ContactListsStatus.Hidden }; ContactListsService service = ConstantContact.ListsService(); existingList = await service.CreateContactListAsync(newList); } if (existingList != null) { var l = new ConstantContactModel { ListName = existingList.Name, ListId = existingList.Id, Status = existingList.Status, CreatedDate = existingList.CreatedDate, ModifiedDate = existingList.ModifiedDate, ContactCount = existingList.ContactCount }; model.Add(l); } } return(model); }
public static async Task <ContactList> GetListByListName(string name, bool create = false) { IEnumerable <ContactList> allLists = await ConstantContact.GetAllLists(); var rtnval = (from list in allLists where string.Equals(list.Name.ToLower(), name.ToLower(), StringComparison.Ordinal) select list).FirstOrDefault(); if (rtnval == null && create) { ContactList newList = new ContactList { Name = name, Status = ContactListsStatus.Hidden }; ContactListsService service = ConstantContactHelper.ListsService(); ContactList y = await service.CreateContactListAsync(newList); return(y); } return(rtnval); }
public async Task <ContactList> FindExistingContactList(string contactListName) { IEnumerable <ContactList> allLists = await ConstantContact.GetAllLists(); return((from cx in allLists where cx.Name == contactListName select cx).FirstOrDefault()); }