/// <summary> /// Add new contacts to an existing sub-campaign /// </summary> /// <param name="lstContactIds"></param> /// <param name="SubCampaignId"></param> public static void AddContactsToSubCampaign(List<int> lstContactIds, int SubCampaignId) { BrightPlatformEntities _efDbModel = new BrightPlatformEntities(UserSession.EntityConnection); int? _FinalListId = _efDbModel.final_lists.FirstOrDefault(i => i.sub_campaign_id == SubCampaignId).id; if (_FinalListId > 0) { foreach (int _ContactId in lstContactIds) { sub_campaign_contact_lists _item = new sub_campaign_contact_lists() { final_list_id = (int)_FinalListId, contact_id = _ContactId, created_by = UserSession.CurrentUser.UserId, created_on = DateTime.Now, active = true, modified = false, priority = null, in_list = false }; _efDbModel.sub_campaign_contact_lists.AddObject(_item); } _efDbModel.SaveChanges(); } }
/// <summary> /// Save updated subcampaign contact lists /// </summary> public static void SaveFinalCallListContacts(List<CTFinalCallListContact> Items, int SubCampaignId) { bool _HasUpdates = false; sub_campaign_contact_lists ItemToupdate = new sub_campaign_contact_lists(); BrightPlatformEntities objDbModel = new BrightPlatformEntities(UserSession.EntityConnection); foreach (CTFinalCallListContact item in Items) { ItemToupdate = null; ItemToupdate = objDbModel.sub_campaign_contact_lists.FirstOrDefault(i => i.id == item.id); if (ItemToupdate == null) continue; ItemToupdate.priority = item.priority; ItemToupdate.modified = true; objDbModel.sub_campaign_contact_lists.ApplyCurrentValues(ItemToupdate); _HasUpdates = true; } if (_HasUpdates) { var item = objDbModel.final_lists.FirstOrDefault(i => i.sub_campaign_id == SubCampaignId); if (item != null) { item.modified_by = UserSession.CurrentUser.UserId; item.modified_on = DateTime.Now; } objDbModel.SaveChanges(); } }