/// <summary> /// Creates a Flex Field folder /// </summary> /// <param name="folder">Folder to create</param> /// <returns>Created folder, with filled id</returns> public async Task<FlexFieldFolder> CreateFolder(FlexFieldFolder folder) { folder.Id = Guid.NewGuid().ToString(); await _FolderCollection.InsertOneAsync(folder); return folder; }
/// <summary> /// Returns a folder by its Id /// </summary> /// <param name="folderId">Folder id</param> /// <returns>Folder</returns> public async Task<FlexFieldFolder> GetFolderById(string folderId) { FlexFieldFolder folder = await _FolderCollection.Find(f => f.Id == folderId).FirstOrDefaultAsync(); return folder; }
/// <summary> /// Updates a folder /// </summary> /// <param name="folder">Folder</param> /// <returns>Task</returns> public async Task UpdateFolder(FlexFieldFolder folder) { await _FolderCollection.UpdateOneAsync(Builders<FlexFieldFolder>.Filter.Eq(f => f.Id, folder.Id), Builders<FlexFieldFolder>.Update.Set(p => p.Name, folder.Name).Set(p => p.Description, folder.Description). Set(p => p.ImageFile, folder.ImageFile).Set(p => p.ThumbnailImageFile, folder.ThumbnailImageFile)); }
/// <summary> /// Deletes a folder /// </summary> /// <param name="folder">Folder to delete</param> /// <returns>Task</returns> public async Task DeleteFolder(FlexFieldFolder folder) { DeleteResult result = await _FolderCollection.DeleteOneAsync(f => f.Id == folder.Id); }
/// <summary> /// Updates a folder /// </summary> /// <param name="folder">Folder</param> /// <returns>Task</returns> public async Task UpdateFolder(FlexFieldFolder folder) { await _FolderCollection.UpdateOneAsync(Builders <FlexFieldFolder> .Filter.Eq(f => f.Id, folder.Id), Builders <FlexFieldFolder> .Update.Set(p => p.Name, folder.Name)); }