Inheritance: Controller
示例#1
0
        public ActionResult Album(string DropDownList, string Submit, AlbumViewModel avm)
        {
            //If the go button was pushed and the dropdown was delete
            if (Submit != null && DropDownList.Equals("Delete"))
            {
                //Call Delete Method
                DeleteImage deleteImage = new DeleteImage();
                deleteImage.deleteMultipleImages(Request, Server);
                DeleteFolder deleteFolder = new DeleteFolder();
                deleteFolder.deleteFolder(Request, Server);
            }
            if (Submit != null && DropDownList.Equals("Move"))
            {

            }
            // Recreate the grid tables
            AlbumGrid ag = new AlbumGrid(dbContext);
            avm.AlbumGridTable = ag.CreateTable(avm.FolderID);

                /*
            AlbumViewModel avm = new AlbumViewModel
            {
                AlbumGridTable = (ag.CreateTable(folderID)),
                InFolderID = f.getParentID(folderID).ToString()
            };
                 * */

            //Re-load the view
            return View(avm);
        }
示例#2
0
        public int deleteFolderChain(Folder DeleteMe)
        {
            PAWAContext db = new PAWAContext();
            AlbumGrid toolbelt = new AlbumGrid(dbContext);
            IEnumerable<Folder> listOfInternalFolders = toolbelt.GetFolders(DeleteMe.FolderID);
            IEnumerable<PAWA.Models.File> listOfInternalFiles = toolbelt.GetFiles(DeleteMe.FolderID);

            int nFolderDel = 0;
            int lengthOfInternalFolders;

            if (listOfInternalFolders.Count() > 0)
            {
                lengthOfInternalFolders = listOfInternalFolders.Count();
            }
            else
            {
                lengthOfInternalFolders = 0;
            }

            for (int i = 0; i < lengthOfInternalFolders; i++)
            {
                Folder delFolder = listOfInternalFolders.ElementAt(0);
                nFolderDel += deleteFolderChain(delFolder);
            }

            deleteMultipleFiles(listOfInternalFiles);
            dbContext.Folders.Remove(DeleteMe);
            dbContext.SaveChanges();
            return nFolderDel;
        }
示例#3
0
        //
        // GET: /Home/AlbumTree
        public ActionResult Album(int? folderID = null)
        {
            var InFolderId = (from f in dbContext.Folders
                             where f.FolderID == folderID
                             select f.InFolderID).SingleOrDefault();

            AlbumGrid ag = new AlbumGrid(dbContext);
            AlbumViewModel avm = new AlbumViewModel
            {
                AlbumGridTable = (ag.CreateTable(folderID)),
                FolderID = folderID,
                InFolderID = InFolderId
            };

            return View(avm);
        }
示例#4
0
        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);
        }