public static async Task <List <ConstantContactModel> > Create(List <string> ccLists) { List <ConstantContactModel> model = new List <ConstantContactModel>(); var myClass = new OldConstantContact(); var t = await myClass.Initialize(); AllContactLists = t.ToList(); 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 = ConstantContactHelper.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); }