Skip to content
Rasmus Wulff Jensen edited this page May 26, 2023 · 7 revisions

Back to Checklist Features

Add a Checklist to the card

Signature

/// <summary>
/// Add a Checklist to the card
/// </summary>
/// <param name="cardId">Id of the Card</param>
/// <param name="checklist">The Checklist to add</param>
/// <param name="ignoreIfAChecklistWithThisNameAlreadyExist">If true the card will be checked if a checklist with the same name (case sensitive) exists and if so return that instead of creating a new</param>
/// <param name="cancellationToken">Cancellation Token</param>
/// <returns>New or Existing Checklist with same name</returns>
public async Task<Checklist> AddChecklistAsync(string cardId, Checklist checklist, bool ignoreIfAChecklistWithThisNameAlreadyExist = false, CancellationToken cancellationToken = default) {...}

Examples

var cardId = "63c939a5cea0cb006dc9e9dd";

var checklistItems = new List<ChecklistItem>
{
    new ChecklistItem("Item A"),
    new ChecklistItem("Item B"),
    new ChecklistItem("Item C"),
};
var checklist = new Checklist("My Cool Checklist", checklistItems);
var checklistAdded = await _trelloClient.AddChecklistAsync(cardId, checklist);

var newChecklistWithSameName = new Checklist("My Cool Checklist", checklistItems);

//This call will NOT create a second checklist as the name is the same
var sameAsChecklistAdded = await _trelloClient.AddChecklistAsync(cardId, newChecklistWithSameName, ignoreIfAChecklistWithThisNameAlreadyExist: true);

//This call WILL create a second checklist with the same name as we do not ignore the same name
var secondAddedChecklist = await _trelloClient.AddChecklistAsync(cardId, newChecklistWithSameName, ignoreIfAChecklistWithThisNameAlreadyExist: false);

Clone this wiki locally