Skip to content

Latest commit

 

History

History
100 lines (74 loc) · 3.23 KB

folder.md

File metadata and controls

100 lines (74 loc) · 3.23 KB

Folders

Case files can be assigned to folders in order to group them together. The folders available from the API corresponds to the folders seen in the Penneo WebApp.

Creating a folder

A folder is simply identified by its title. The example below shows how to create a folder:

// Create a new folder object
var myFolder = new Folder();

// Set the folder title
myFolder.Title = "New Folder";

// Persist the new object
await myFolder.PersistAsync(connector);

Manipulating folder contents

An empty folder is not much fun. The examples below shows how to assign and unassign case files and validations, and how to list the contents of a folder:

Case files

// Assign a case file to a folder
await myFolder.AddCaseFileAsync(con, caseFile);

// Get a list of all the case files in the folder
var caseFiles = await myFolder.GetCaseFilesAsync(connector);
foreach (var caseFile in caseFiles) {
	Console.WriteLine(caseFile.Title);	
}

// Now, remove that same case file again
await myFolder.RemoveCaseFileAsync(connector, caseFile);

Validations

// Assign a validation to a folder
await myFolder.AddValidation(connector, validation1);

// Get a list of all the validations in the folder
var validations = await myFolder.GetValidations(connector);
foreach (var validation in validations) {
    Console.WriteLine(validation.Title);  
}

// Now, remove that same validation again
await myFolder.RemoveValidation(connector, validation);

Retrieve existing folders

There is several ways to retrieve folders from Penneo. Available methods for retrieving folders are:

  • Find(int id) Find one specific folder by its ID.
  • FindAll Find all folders accessible by the authenticated user.
  • FindBy(Dictionary<string, object> criteria = null, Dictionary<string, string> orderBy = null, int? limit = null, int? offset = null) Find all folders matching criteria ordered by orderBy. If limit is set, only limit results are returned. If offset is set, the offset first results are skipped. Criteria can either be title or metaData.
  • FindOneBy(Dictionary<string, object> criteria = null, Dictionary<string, string> orderBy = null) Same as FindBy setting limit = 1 and offset = null

Below is a couple of examples:

var query = new Query(connector);

// Retrieve all folders
var myFolders = await query.FindAll<Folder>();

// Retrieve a specific folder (by id)
var myFolder = await query.Find<Folder>(14284);

// Retrieve all folders that contains the word "the" in their title and sort descending on folder title
var myDocuments = await query.FindBy<Folder>(
	criteria: new Dictionary<string, object>{ { "title", "the" } },
	orderBy: new Dictionary<string, string>(){ { "title", "desc" } }
);

// Retrieve folders from offset 10 until 110 ordered by title in ascending order
var myFolders = await query.FindBy<Folder>(	
	orderBy: new Dictionary<string, string>(){ {"title", "asc" } },
	limit: 10,
	offset: 100
);

Deleting a folder

Folders can be deleted, even if the contain case files. This will only delete the folder and its mappings, NOT the case files. To delete a folder do the following:

// Delete a folder
myFolder.Delete(connector);