예제 #1
0
        public ActionResult Get(string folderID, string Id, string GTType)
        {
            if (String.IsNullOrEmpty(folderID) == true)
            {
                folderID = "";
            }
            if (String.IsNullOrEmpty(Id) == true)
            {
                Id = "";
            }

            if (GTType == "File")
            {
                var folders = _folderRepository.FindBy(x => x.UserID == UserId && x.ParentID == folderID).ToList();
                var files   = _fileRepository.FindBy(x => x.UserID == UserId && x.FolderID == folderID).ToList();

                var navFolders = new List <Folder>();
                for (int i = 0; i < 10; i++)
                {
                    if (folderID == "")
                    {
                        navFolders.Add(new Folder {
                            Name = "All Files", Id = "", Discriminator = ""
                        });
                        break;
                    }
                    else
                    {
                        var folder = _folderRepository.GetSingle(folderID);
                        navFolders.Add(folder);

                        folderID = folder.ParentID;
                    }
                }
                navFolders[0].Discriminator = "LastOne";

                return(Json(new { Folders = folders, Files = files, NavFolders = navFolders }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var folders = _gtFolderRepository.FindBy(x => x.ParentID == folderID && x.GTID == Id).ToList();
                var files   = _gtFileRepository.FindBy(x => x.GTID == Id && x.GTType == GTType && x.FolderID == folderID).ToList();

                var navFolders = new List <GTFolder>();
                for (int i = 0; i < 10; i++)
                {
                    if (folderID == "")
                    {
                        navFolders.Add(new GTFolder {
                            Name = "All Files", Id = "", Discriminator = ""
                        });
                        break;
                    }
                    else
                    {
                        var folder = _gtFolderRepository.GetSingle(folderID);
                        navFolders.Add(folder);

                        folderID = folder.ParentID;
                    }
                }
                navFolders[0].Discriminator = "LastOne";

                return(Json(new { Folders = folders, Files = files, NavFolders = navFolders }, JsonRequestBehavior.AllowGet));
            }
        }