Consents


List of examples:

Consents




// Creates a new consent object
ConsentInfo newConsent = new ConsentInfo()
{
    ConsentName = "NewConsent",
    ConsentDisplayName = "New Consent",
};

// Defines and sets content of the consent
string shortText = "This is a sample consent.";
string fullText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
newConsent.UpsertConsentText("en-us", shortText, fullText);

// Saves the created consent object to the database
newConsent.Update();


> Back to list of examples




// Gets the consent
ConsentInfo existingConsent = ConsentInfoProvider.GetConsentInfo("NewConsent");

// Defines and updates content of the consent
string shortText = existingConsent.GetConsentText("en-us").ShortText.Replace("consent", "consent declaration");
string fullText = existingConsent.GetConsentText("en-us").FullText;
existingConsent.UpsertConsentText("en-us", shortText, fullText);

// Saves the created consent object to the database.
// If at least one contact gave an agreement with this consent,
// the content of the consent is archived before updating.
existingConsent.Update();


> Back to list of examples




// Gets the consent
ConsentInfo existingConsent = ConsentInfoProvider.GetConsentInfo("NewConsent");

// Defines and updates content of the Spanish language variant
string shortText = "Esta es una muestra de consentimiento.";
string fullText = "ESP Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
existingConsent.UpsertConsentText("es-es", shortText, fullText);

// Saves the created consent object to the database
existingConsent.Update();


> Back to list of examples




// Gets the consent
ConsentInfo deleteConsent = ConsentInfoProvider.GetConsentInfo("NewConsent");

if (deleteConsent != null)
{
    // Deletes the consent
    ConsentInfoProvider.DeleteConsentInfo(deleteConsent);
}


> Back to list of examples




// Gets the consent
ConsentInfo consent = ConsentInfoProvider.GetConsentInfo("NewConsent");

// Gets the first contact whose name is John Doe
ContactInfo contact = ContactInfoProvider.GetContacts()
                                         .WhereEquals("ContactLastname", "Doe")
                                         .WhereEquals("ContactFirstName", "John")
                                         .TopN(1)
                                         .FirstOrDefault();

// Initializes an instance of the consent agreement service
IConsentAgreementService consentAgreementService = Service.Resolve<IConsentAgreementService>();

// Creates a consent agreement signifying that the contact has given an agreement with the consent
consentAgreementService.Agree(contact, consent);


> Back to list of examples




// Gets the consent
ConsentInfo consent = ConsentInfoProvider.GetConsentInfo("NewConsent");

// Gets the first contact whose name is John Doe
ContactInfo contact = ContactInfoProvider.GetContacts()
                                         .WhereEquals("ContactLastname", "Doe")
                                         .WhereEquals("ContactFirstName", "John")
                                         .TopN(1)
                                         .FirstOrDefault();

// Initializes an instance of the consent agreement service
IConsentAgreementService consentAgreementService = Service.Resolve<IConsentAgreementService>();

// Checks if the contact has given an agreement with the consent
bool agreed = consentAgreementService.IsAgreed(contact, consent);


> Back to list of examples




// Gets the consent
ConsentInfo consent = ConsentInfoProvider.GetConsentInfo("NewConsent");

// Gets the first contact whose name is John Doe
ContactInfo contact = ContactInfoProvider.GetContacts()
                                         .WhereEquals("ContactLastname", "Doe")
                                         .WhereEquals("ContactFirstName", "John")
                                         .TopN(1)
                                         .FirstOrDefault();

// Initializes an instance of the consent agreement service
IConsentAgreementService consentAgreementService = Service.Resolve<IConsentAgreementService>();

// Revokes the previously created consent agreement
consentAgreementService.Revoke(contact, consent);


> Back to list of examples




// Gets the first contact whose name is John Doe
ContactInfo contact = ContactInfoProvider.GetContacts()
                                         .WhereEquals("ContactLastname", "Doe")
                                         .WhereEquals("ContactFirstName", "John")
                                         .TopN(1)
                                         .FirstOrDefault();

// Initializes an instance of the consent agreement service
IConsentAgreementService consentAgreementService = Service.Resolve<IConsentAgreementService>();

// Gets the list of consents with which the contact gave a consent agreement.
// The 'Consent' object contains information about a consent declaration. The 'GetConsentText'
// method gets the content of the consent from either the current consent declaration or from
// the consent archive, depending on the version of the consent with which the contact gave
// the agreement.
IEnumerable<Consent> consents = consentAgreementService.GetAgreedConsents(contact);

// Iterates through the retrieved consents
foreach(Consent consent in consents)
{
    // Gets the properties of the individual consents
    string displayName = consent.DisplayName;
    int id = consent.Id;

    // Gets the content of the consent
    string shortText = consent.GetConsentText("en-us").ShortText;
    string fullText = consent.GetConsentText("en-us").FullText;
}


> Back to list of examples