예제 #1
0
        private void RemoveFromCurrentFolder(IStorageFile entity)
        {
            List <StorageFolder> folders = _storageFolderRepository.Get().Where(c => c.Files.Any(t => t.Id == entity.Id)).ToList();

            int lastIndex = entity.Path.LastIndexOf('/');
            var path      = entity.Path;

            if (lastIndex != -1)
            {
                path = entity.Path.Substring(0, lastIndex);
            }

            //remove from folder if new path differs
            if (folders.Any() && folders[0].Path != path)
            {
                StorageFolder       currentFolder = folders[0];
                List <IStorageFile> childFiles    = currentFolder.Files;
                int index = -1;

                foreach (IStorageFile file in childFiles)
                {
                    if (file.Id == entity.Id)
                    {
                        index = childFiles.FindIndex(c => c.Id == file.Id);
                    }
                }

                if (index != -1)
                {
                    childFiles.RemoveAt(index);
                }

                currentFolder.Files = childFiles;

                _storageFolderRepository.Update(currentFolder);
            }
        }
예제 #2
0
 public IEnumerable <IStorageFile> Get()
 {
     return(_repository.Get());
 }