Ejemplo n.º 1
0
 /// <summary>
 /// Creates the specified Item using PUT.
 /// </summary>
 /// <param name="item">The Item to create.</param>
 /// <returns>The created Item.</returns>
 public async Task<Item> CreateAsync(Item item)
 {
     this.ContentType = "application/json";
     this.Method = "PUT";
     var entity = await this.SendAsync<Item>(item);
     this.InitializeCollectionProperties(entity);
     return entity;
 }
 public ItemModel(Item item)
 {
     this.Item = item;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="item">The <see cref="Item"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(Item item)
        {
        
            if (item != null && item.AdditionalData != null)
            {
        
                if (item.Permissions != null && item.Permissions.CurrentPage != null)
                {
                    item.Permissions.AdditionalData = item.AdditionalData;

                    object nextPageLink;
                    item.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        item.Permissions.InitializeNextPageRequest(
                            this.OneDriveClient,
                            nextPageLinkString);
                    }
                }
        
                if (item.Versions != null && item.Versions.CurrentPage != null)
                {
                    item.Versions.AdditionalData = item.AdditionalData;

                    object nextPageLink;
                    item.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        item.Versions.InitializeNextPageRequest(
                            this.OneDriveClient,
                            nextPageLinkString);
                    }
                }
        
                if (item.Children != null && item.Children.CurrentPage != null)
                {
                    item.Children.AdditionalData = item.AdditionalData;

                    object nextPageLink;
                    item.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        item.Children.InitializeNextPageRequest(
                            this.OneDriveClient,
                            nextPageLinkString);
                    }
                }
        
                if (item.Thumbnails != null && item.Thumbnails.CurrentPage != null)
                {
                    item.Thumbnails.AdditionalData = item.AdditionalData;

                    object nextPageLink;
                    item.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        item.Thumbnails.InitializeNextPageRequest(
                            this.OneDriveClient,
                            nextPageLinkString);
                    }
                }
        
            }

        
        }
 /// <summary>
 /// Adds the specified Item to the collection via POST.
 /// </summary>
 /// <param name="item">The Item to add.</param>
 /// <returns>The created Item.</returns>
 public Task<Item> AddAsync(Item item)
 {
     this.ContentType = "application/json";
     this.Method = "POST";
     return this.SendAsync<Item>(item);
 }
Ejemplo n.º 5
0
        private async Task CreateBackupFolder()
        {
            var folderToCreate = new Item {Name = OneDriveAuthenticationConstants.BACKUP_FOLDER_NAME, Folder = new Folder()};

            var root = await OneDriveClient.Drive.Root.Request().GetAsync();

            BackupFolder = await OneDriveClient.Drive.Items[root.Id].Children.Request()
                .AddAsync(folderToCreate);
        }
Ejemplo n.º 6
0
        private async Task GetBackupFolder()
        {
            var children = await OneDriveClient.Drive.Root.Children.Request().GetAsync();
            BackupFolder = children.CurrentPage.FirstOrDefault(x => x.Name == OneDriveAuthenticationConstants.BACKUP_FOLDER_NAME);

            if (BackupFolder == null)
            {
                await CreateBackupFolder();
            }
        }