Exemplo n.º 1
0
    /// <summary>
    /// Gets and bulk updates messages created by multiple executions of the first method. Called when the "Get and bulk update messages" button is pressed.
    /// Expects the CreateMessage method to be run first and multiple times to demonstrate the full functionality.
    /// </summary>
    private bool GetAndBulkUpdateMessages()
    {
        // Prepare the parameters
        string where = "[MessageSubject] = 'API example message'";

        // Get the data
        DataSet messages = MessageInfoProvider.GetMessages(where, null);

        if (!DataHelper.DataSourceIsEmpty(messages))
        {
            // Loop through the individual items
            foreach (DataRow messageDr in messages.Tables[0].Rows)
            {
                // Create object from DataRow
                MessageInfo modifyMessage = new MessageInfo(messageDr);

                // Update the properties
                modifyMessage.MessageBody = modifyMessage.MessageBody.ToLowerCSafe();

                // Save the changes
                MessageInfoProvider.SetMessageInfo(modifyMessage);
            }

            return(true);
        }

        return(false);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Deletes message(s). Called when the "Delete message" button is pressed.
    /// Expects the CreateMessage method to be run first.
    /// </summary>
    private bool DeleteMessage()
    {
        // Prepare the parameters
        string where = "[MessageSubject] = 'API example message'";

        // Get the message
        DataSet messages = MessageInfoProvider.GetMessages(where, null);

        if (!DataHelper.DataSourceIsEmpty(messages))
        {
            foreach (DataRow messageDr in messages.Tables[0].Rows)
            {
                // Create message object from DataRow
                MessageInfo deleteMessage = new MessageInfo(messageDr);

                // Delete the message
                MessageInfoProvider.DeleteMessageInfo(deleteMessage);
            }

            return(true);
        }

        return(false);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Gets and updates the message created by the previous method. Called when the "Get and update message" button is pressed.
    /// Expects the CreateMessage method to be run first.
    /// </summary>
    private bool GetAndUpdateMessage()
    {
        // Prepare the parameters
        string where = "[MessageSubject] = 'API example message'";

        // Get the data
        DataSet messages = MessageInfoProvider.GetMessages(where, null, 1, null);

        if (!DataHelper.DataSourceIsEmpty(messages))
        {
            // Get the message from the DataSet
            MessageInfo modifyMessage = new MessageInfo(messages.Tables[0].Rows[0]);

            // Update the properties
            modifyMessage.MessageBody = modifyMessage.MessageBody.ToUpper();

            // Save the changes
            MessageInfoProvider.SetMessageInfo(modifyMessage);

            return(true);
        }

        return(false);
    }