Beispiel #1
0
        public async Task <bool> RemoveChild(FolderViewModel Child)
        {
            Child._parent = null;
            await Child.Save();

            if (this._children.Remove(Child))
            {
                this.OnPropertyChanged("Children");
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private async Task AddAllFolders(string rootName)
        {
            var rootFolder = new FolderViewModel(rootName, _folderTree);
            await rootFolder.Save();

            var infolder = await rootFolder.AddChild("In");

            this._emailProvider.InFolderId = infolder.Id;
            var outFolder = await rootFolder.AddChild("Out");

            this._emailProvider.OutFolderId = outFolder.Id;
            var sentFolder = await rootFolder.AddChild("Sent");

            this._emailProvider.SentFolderId = sentFolder.Id;
            var conceptsFolder = await rootFolder.AddChild("Concepts");

            this._emailProvider.ConceptsFolderId = conceptsFolder.Id;
        }
Beispiel #3
0
        public async Task <bool> SetParent(FolderViewModel parent)
        {
            if (_parent == parent)
            {
                return(true);
            }
            if (_parent != null)
            {
                await _parent.RemoveChild(this);
            }
            _parent = parent;
            if (parent == null)
            {
                if (_visualTree?.Children?[0] == null)
                {
                    _folder.Parent = 0;
                }
                else
                {
                    _folder.Parent = _visualTree.Children[0]._parent.Id;
                }
                _parent = null;
                await Save(new List <int>());
            }
            else
            {
                if (parent.Id == 0)
                {
                    await parent.Save();
                }
                _folder.Parent = parent.Id;
                var saved = await Save(new List <int>());

                if (!saved)
                {
                    _folder.Parent = 0;
                    _parent        = null;
                    return(false);
                }
                _parent?.OnPropertyChanged("Children");
            }
            OnPropertyChanged("Path");
            return(true);
        }