private void RecurseForCreateFolderPath(string path, int childId, IStorageEntity obj) { //check for root folder if (string.IsNullOrEmpty(path)) { path = "/"; } IList <StorageFolder> array = _storageFolderRepository.Find(c => c.Path == path).ToList(); if (!array.Any()) { //folder does not exist so insert and move up StorageFolder folder = new StorageFolder(); folder.Path = path; if (obj != null) { if (obj.GetType() == typeof(StorageFile)) { folder.Files.Add((StorageFile)obj); } if (obj.GetType() == typeof(StorageFolder)) { folder.Folders.Add((StorageFolder)obj); } } folder = _storageFolderRepository.Add(folder); if (!string.IsNullOrEmpty(path.Trim())) { int lastIndex = path.LastIndexOf('/'); if (lastIndex != -1) { path = path.Substring(0, lastIndex); RecurseForCreateFolderPath(path, folder.Id, folder); } } } else { StorageFolder j_obj = array[0]; List <IStorageFile> files = j_obj.Files; var id = j_obj.Id; if (id != childId) { var list = new List <StorageFile>(); foreach (StorageFile file in files) { list.Add(file); } if (!list.Where(c => c.Id == childId).Any()) { files.Add((StorageFile)obj); } } j_obj.Files = files; _storageFolderRepository.Update(j_obj); } }
private StorageItem GetStorageItem(IStorageEntity storageEntity) { return(GetStorageItem(storageEntity, storageEntity.GetIdentity(), GetStorageType(storageEntity.GetType()))); }