public ActionResult MoveImageTo(MoveItemList moveItemList) { IList<string> selectedItems = new List<string> { }; if (moveItemList.selected != null) { selectedItems = moveItemList.selected.Split((new char[] { ',' }), StringSplitOptions.RemoveEmptyEntries); } int? newFolderID = Convert.ToInt32(moveItemList.destinationFolder); int? currentFolder = Convert.ToInt32(moveItemList.sourceFolder); if (currentFolder <= 0) { currentFolder = null; } IList<Folder> listOfUserFolders; IEnumerable<File> listOfUserFiles; { Tools toolbelt = new Tools(); listOfUserFolders = toolbelt.getFolders(WebSecurity.CurrentUserId); } { AlbumGrid toolbelt = new AlbumGrid(dbContext); listOfUserFiles = toolbelt.GetFiles(currentFolder); } int amountOfUserFolders = listOfUserFolders.Count; IList<File> filesToMove = new List<File>(); string ReturnValue = ""; ReturnValue += "Selected Items Count : " + selectedItems.Count + " : " + selectedItems.Count(); ReturnValue += "\nFolders Count : " + listOfUserFolders.Count + " : " + listOfUserFolders.Count(); ReturnValue += "\nFiles Count : " + listOfUserFiles.Count() ; if (listOfUserFiles.Count() > 0){ReturnValue += "\nFileID : " + listOfUserFiles.ElementAt(listOfUserFiles.Count()-1).Description;} ReturnValue += "\nNew Folder ID : " + newFolderID.ToString(); for (int i = 0; i < amountOfUserFolders; i++){ // Go through every folder if (listOfUserFolders.ElementAt(i).FolderID == newFolderID){ // FolderID(i) == FolderID.FromAJAX // MAKE SURE the folder exists int numberOfFilesInFolder = listOfUserFiles.Count(); for (int n = 0; n < numberOfFilesInFolder; n++) { for (int j = 0; j < selectedItems.Count; j++) { int fileIdFromAJAX = -1; /* Catch Bogus Array values*/ try { fileIdFromAJAX = Convert.ToInt32(selectedItems.ElementAt(j)); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } if (listOfUserFiles.ElementAt(n).FileID == fileIdFromAJAX) { filesToMove.Add(listOfUserFiles.ElementAt(n)); } } } } } for (int i = 0; i < filesToMove.Count; i++) { MoveFile(filesToMove.ElementAt(i), newFolderID); ReturnValue += "\nFilesToMove : " + filesToMove.ElementAt(i).Description; } return Content(ReturnValue); }
public ActionResult MoveFolderTo(MoveItemList moveItemList) { Tools toolbelt = new Tools(); int? newFolderID; int? currentFolder; IList<string> selectedItems = new List<string> { }; {// Initialise Posted string variables into workable data if (moveItemList.selected != null) { selectedItems = moveItemList.selected.Split((new char[] { ',' }), StringSplitOptions.RemoveEmptyEntries); } newFolderID = Convert.ToInt32(moveItemList.destinationFolder); currentFolder = Convert.ToInt32(moveItemList.sourceFolder); if (currentFolder <= 0) { currentFolder = null; } } string ReturnValue = "Count :" + selectedItems.Count ; // Move all the folders that need be moved. for (int i = 0; i < selectedItems.Count ; i++) { bool SuccessfulMove = toolbelt.moveFolder(WebSecurity.CurrentUserId, selectedItems.ElementAt(i).ToString(), newFolderID); ReturnValue += "Folder : " + selectedItems.ElementAt(i).ToString() + " : Success : " + SuccessfulMove + "\n"; } return Content(ReturnValue); }