public static void AcceptCategory(CmpCategoryModel model, bool consent = true) { var cat = new ConsentGdprSaveAndExitVariablesCategory(model._id, model.iabId, model.type, consent, false); if (!categories[CmpCampaignPopupQueue.CurrentCampaignToShow()].Exists(x => (x._id != null && cat._id != null && cat._id.Equals(x._id)))) { categories[CmpCampaignPopupQueue.CurrentCampaignToShow()].Add(cat); } List <CmpCategoryConsentVendorModel> vendors = new List <CmpCategoryConsentVendorModel>(); foreach (var vendor in model.requiringConsentVendors) { vendors.Add(vendor); } vendors.AddRange(model.legIntVendors); foreach (var vendor in vendors) { int?iabId = null; foreach (var v in CmpLocalizationMapper.CurrentVendors) { if (v.vendorId != null && v.vendorId.Equals(vendor.vendorId)) { if (v.iabId.HasValue) { iabId = v.iabId.Value; } v.accepted = consent; } //List init if (!categoryVendors[CmpCampaignPopupQueue.CurrentCampaignToShow()].ContainsKey(model._id)) { categoryVendors[CmpCampaignPopupQueue.CurrentCampaignToShow()][model._id] = new List <ConsentGdprSaveAndExitVariablesVendor>(); } //Duplicate check if (!categoryVendors[CmpCampaignPopupQueue.CurrentCampaignToShow()][model._id].Exists(x => (x._id != null && vendor.vendorId != null && x._id.Equals(vendor.vendorId)) || (x.name != null && vendor.name != null && vendor.name.Equals(x.name)))) { categoryVendors[CmpCampaignPopupQueue.CurrentCampaignToShow()][model._id].Add(new ConsentGdprSaveAndExitVariablesVendor(vendor.vendorId, iabId, vendor.vendorType, true, false, vendor.name)); isAcceptedVendorsChanged = true; } } } foreach (var category in CmpLocalizationMapper.CurrentCategories) { if (category._id.Equals(model._id)) { category.accepted = consent; } } isAcceptedCategoriesChanged = true; }
public static void ExcludeCategory(string id, bool consented = false) { ConsentGdprSaveAndExitVariablesCategory excluded = null; foreach (var cat in categories[CmpCampaignPopupQueue.CurrentCampaignToShow()]) { if (cat._id.Equals(id)) { excluded = cat; } } if (excluded != null) { categories[CmpCampaignPopupQueue.CurrentCampaignToShow()].Remove(excluded); if (categoryVendors[CmpCampaignPopupQueue.CurrentCampaignToShow()].ContainsKey(excluded._id) && categoryVendors[CmpCampaignPopupQueue.CurrentCampaignToShow()][excluded._id] != null) { categoryVendors[CmpCampaignPopupQueue.CurrentCampaignToShow()].Remove(excluded._id); isAcceptedVendorsChanged = true; } } foreach (var category in CmpLocalizationMapper.CurrentCategories) { if (category._id.Equals(id)) { category.accepted = consented; if (categoryVendors[CmpCampaignPopupQueue.CurrentCampaignToShow()].ContainsKey(category._id) && categoryVendors[CmpCampaignPopupQueue.CurrentCampaignToShow()][category._id] != null) { categoryVendors[CmpCampaignPopupQueue.CurrentCampaignToShow()].Remove(category._id); isAcceptedVendorsChanged = true; } List <CmpCategoryConsentVendorModel> vendoritos = new List <CmpCategoryConsentVendorModel>(); vendoritos.AddRange(category.legIntVendors); vendoritos.AddRange(category.disclosureOnlyVendors); vendoritos.AddRange(category.requiringConsentVendors); ConsentGdprSaveAndExitVariablesVendor vendo = null; foreach (var vendorez in vendoritos) { if (vendors[CmpCampaignPopupQueue.CurrentCampaignToShow()].Exists(x => x._id != null && vendorez.vendorId != null && vendorez.vendorId.Equals(x._id))) { vendo = vendors[CmpCampaignPopupQueue.CurrentCampaignToShow()].Find(x => x._id != null && vendorez.vendorId != null && vendorez.vendorId.Equals(x._id)); } } if (vendo != null) { if (CmpLocalizationMapper.CurrentVendors != null) { foreach (var vendor in CmpLocalizationMapper.CurrentVendors) { if (vendor.vendorId != null && vendo._id != null && vendo._id.Equals(vendor.vendorId) || vendor.name.Equals(vendo.name)) { vendor.accepted = consented; } } } vendors[CmpCampaignPopupQueue.CurrentCampaignToShow()].Remove(vendo); isAcceptedVendorsChanged = true; } break; } } ConsentGdprSaveAndExitVariablesCategory excluded2 = null; foreach (var cat in previousSessionCategories[CmpCampaignPopupQueue.CurrentCampaignToShow()]) { if (cat._id.Equals(id)) { excluded2 = cat; } } if (excluded2 != null) { previousSessionCategories[CmpCampaignPopupQueue.CurrentCampaignToShow()].Remove(excluded2); } isAcceptedCategoriesChanged = true; }