Exemple #1
0
        public void RemoveFolder(int userId, int folderId)
        {
            IEnumerable <File> files      = _files.GetAllFilesInFolder(folderId).ToList();
            IEnumerable <int>  foldersIds = _folders.GetDescendantFoldersIds(folderId).ToList();
            //!!
            IEnumerable <Folder> folders = foldersIds.Select(id => _folders.GetById(id)).ToList();

            foreach (var file in files)
            {
                _files.Remove(file);
            }
            foreach (var folder in folders)
            {
                _folders.Remove(folder);
            }

            var user = _users.GetById(userId);

            _storage.DeleteFiles(user, files);
            _files.SaveChanges();
            _folders.SaveChanges();
        }