public static bool RegisterChanges( List <string> JsonChanges, List <string> NeededChanges ) { foreach (string PreCheck in JsonChanges) { DataHistoryChange PreCheckObj = JsonConvert.DeserializeObject <DataHistoryChange>(PreCheck); if (NeededChanges.Contains(PreCheckObj.Type)) { NeededChanges.Remove(PreCheckObj.Type); } } if (NeededChanges.Count != 0) { return(false); } // data is comming like this: ["{}", "{}"] foreach (string JsonObjectString in JsonChanges) { DataHistoryChange ChangeObject = JsonConvert.DeserializeObject <DataHistoryChange>(JsonObjectString); DataConsentTDS Set = new DataConsentTDS(); // generate and add new row for p_consent_history PConsentHistoryRow NewRow = Set.PConsentHistory.NewRowTyped(); NewRow.EntryId = -1; NewRow.PartnerKey = ChangeObject.PartnerKey; NewRow.Type = ChangeObject.Type; NewRow.Value = ChangeObject.Value; NewRow.ConsentDate = ChangeObject.ConsentDate; NewRow.ChannelCode = ChangeObject.ChannelCode; Set.PConsentHistory.Rows.Add(NewRow); // generate and add each row for a allowed purpose in p_consent_history_permission foreach (string AllowedPuroseCode in ChangeObject.Permissions.Split(',')) { if (AllowedPuroseCode.Trim().Equals("")) { continue; } // catch non permission values PConsentHistoryPermissionRow NewPermRow = Set.PConsentHistoryPermission.NewRowTyped(); NewPermRow.PurposeCode = AllowedPuroseCode; NewPermRow.ConsentHistoryEntry = -1; Set.PConsentHistoryPermission.Rows.Add(NewPermRow); } DataConsentTDSAccess.SubmitChanges(Set); } return(true); }
public static bool EditHistory( Int64 APartnerKey, string ADataType, string AChannelCode, DateTime AConsentDate, string AConsentCodes, out TVerificationResultCollection AVerificationResult ) { AVerificationResult = new TVerificationResultCollection(); DataConsentTDS LastEntry = LastKnownEntry(APartnerKey, ADataType); DataConsentTDSPConsentHistoryRow LastEntryRow = LastEntry.PConsentHistory[0]; // tried to save with same permissions, we skip these actions and throw a error if (LastEntryRow.AllowedPurposes == AConsentCodes && LastEntryRow.ConsentDate == AConsentDate && LastEntryRow.ChannelCode == AChannelCode) { AVerificationResult.Add(new TVerificationResult("error", "no_changes", TResultSeverity.Resv_Critical)); return(false); } DataHistoryChange ToChange = new DataHistoryChange { ConsentDate = AConsentDate, ChannelCode = AChannelCode, PartnerKey = APartnerKey, Type = ADataType, Value = LastEntryRow.Value, Permissions = AConsentCodes }; String ToRegister = JsonConvert.SerializeObject(ToChange); List <string> JsonList = new List <string> { ToRegister }; RegisterChanges(JsonList, new List <string>() { ADataType }); return(true); }