Get child items under "My drive" item sample.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FarmmapsApi.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -27,11 +28,21 @@ namespace FarmmapsApiSamples
|
||||
var user = await _farmmapsApiService.GetCurrentUserCodeAsync();
|
||||
_logger.LogInformation($"Usercode: {user}");
|
||||
|
||||
var roots = await _farmmapsApiService.GetCurrentUserRootsAsync();
|
||||
var roots = (await _farmmapsApiService.GetCurrentUserRootsAsync()).ToList();
|
||||
foreach (var userRoot in roots)
|
||||
{
|
||||
_logger.LogInformation($"{userRoot.Name} - {userRoot.Code}");
|
||||
}
|
||||
|
||||
var myDriveRoot = roots.SingleOrDefault(r => r.Name == "My drive");
|
||||
if(myDriveRoot != null)
|
||||
{
|
||||
var items = await _farmmapsApiService.GetItemChildrenAsync(myDriveRoot.Code);
|
||||
foreach (var item in items)
|
||||
{
|
||||
_logger.LogInformation($"{item.Name} - {item.ItemType}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Reference in New Issue
Block a user