Example #1
0
        protected override void SetItem(string path, object value)
        {
            WriteDebug("SetItem - Path:" + path);

            PSObject fileEntity = PSObject.AsPSObject(value);
            var itemEntityValue = fileEntity.Properties.ToArray();

            var resource = new ResourceFinder(path, _token, AcceptHeader);
            CurrentItem = _responseItemFactory.Create(resource.Get());

            if (itemEntityValue[0].Name == "uploadPath")
            {
                path = CurrentItem.LinkFor("upload");
                var uploadResource = new ResourceUploader(path, _token, AcceptHeader,
                                                          itemEntityValue[0].Value.ToString());
                CurrentItem = _responseItemFactory.Create(uploadResource.SendMutiPartRequest());
            }
            else
            {
                CurrentItem.Title = itemEntityValue[2].Value.ToString();
                CurrentItem.Description = itemEntityValue[1].Value.ToString();

                path = CurrentItem.LinkFor("edit");
                var editedResource = new ResourceModifier(path, _token, AcceptHeader, CurrentItem);
                editedResource.Put();
            }
        }
Example #2
0
        protected override void SetItem(string path, object value)
        {
            PSObject fileEntity = PSObject.AsPSObject(value);
            var itemEntityValue = fileEntity.Properties.ToArray();

            var resource = new ResourceFinder(path, _token, AcceptHeader);
            HuddleResourceObject item;

            if (itemEntityValue[0].Name == "uploadPath")
            {
                item = _responseItemFactory.Create(resource.Get());
                path = item.Links.Single(l => l.Rel == "upload").Href;

                var uploadResource = new ResourceUploader(path, _token, AcceptHeader,
                                                          itemEntityValue[0].Value.ToString());
                item = _responseItemFactory.Create(uploadResource.SendMutiPartRequest());
            }
            else
            {
                item = _responseItemFactory.Create(resource.Get());

                item.Title = itemEntityValue[2].Value.ToString();
                item.Description = itemEntityValue[1].Value.ToString();

                path = item.Links.Single(l => l.Rel == "edit").Href;
                var editedResource = new ResourceModifier(path, _token, AcceptHeader, item);
                editedResource.Put();
            }
        }