Ejemplo n.º 1
0
        public List <FolderDto> GetFolders(FolderFilter input)
        {
            var query = _context.Folders.AsNoTracking().Where(x => !x.isDeleted);

            if (input != null)
            {
                if (input.owner != null)
                {
                    query = query.Where(x => x.owner == input.owner);
                }

                if (input.parentID != 0)
                {
                    query = query.Where(x => x.parentID == input.parentID);
                }
                else
                {
                    query = query.Where(x => x.parentID == null);
                }
            }

            var listOfFolder = query.OrderBy(x => x.parentID).ToList();

            return(listOfFolder.Select(item => _mapper.Map <FolderDto>(item)).ToList());
        }
Ejemplo n.º 2
0
        public void SubfolderSearchAutomatic()
        {
            SetupGetFiles("Scripts", @"*.js", true, new string[] { @"file1.js", @"file2.js", @"Sub\file3.js" });

            FolderFilter[] folderFilterList = new FolderFilter[] { new FolderFilter {
                                                                       Folder = @"Scripts", FilePattern = "*.js", IncludeSubfolders = true
                                                                   } };
            DynamicScriptList dynamicFileList = new DynamicScriptList(@"C:\www", folderFilterList.ToList(), new List <FolderFilter>(), _FileLocatorMock.Object);

            dynamicFileList.Scripts.ShouldAllBeEquivalentTo(new string[] { @"Scripts/file1.js", @"Scripts/file2.js", @"Scripts/Sub/file3.js" });
        }
Ejemplo n.º 3
0
        public ActionResult Index(long?id, FolderFilter filter, FetchOptions options)
        {
            var folder = id.HasValue ? folderRepository.Load(id.Value) : null;
            var model  = new FolderViewModel
            {
                CurrentFolder = folder,
                Parent        = folder != null && folder.ParentFolder != null ? folder.ParentFolder : null,
                Folders       = folderRepository.GetFolders(id, filter, options)
            };

            return(View(model));
        }
Ejemplo n.º 4
0
        public void MultipleFolderFilters()
        {
            SetupGetFiles("Scripts", @"*.js", false, new string[] { @"file1.js", @"file2.js" });
            SetupGetFiles(@"Scripts\Sub", @"*.js", false, new string[] { @"file3.js" });

            FolderFilter[] folderFilterList = new FolderFilter[] { new FolderFilter {
                                                                       Folder = @"Scripts", FilePattern = "*.js", IncludeSubfolders = false
                                                                   }, new FolderFilter {
                                                                       Folder = @"Scripts\Sub", FilePattern = "*.js", IncludeSubfolders = false
                                                                   } };
            DynamicScriptList dynamicFileList = new DynamicScriptList(@"C:\www", folderFilterList.ToList(), new List <FolderFilter>(), _FileLocatorMock.Object);

            dynamicFileList.Scripts.ShouldAllBeEquivalentTo(new string[] { @"Scripts/file1.js", @"Scripts/file2.js", @"Scripts/Sub/file3.js" });
        }
Ejemplo n.º 5
0
        public ActionResult Index(long?root = null)
        {
            User user   = CurrentUser;
            var  filter = new FolderFilter
            {
                User = user,
                Root = root.HasValue ? folderRepository.Load(root.Value) : null
            };
            var folders = folderRepository.Find(filter);

            return(View(new FolderViewModel {
                Folders = folders,
                Entity = filter.Root
            }));
        }
Ejemplo n.º 6
0
        public IList <Folder> GetFolders(long?id, FolderFilter filter = null, FetchOptions options = null)
        {
            var crit = session.CreateCriteria <Folder>();

            SetupFilter(crit, filter);
            if (id.HasValue)
            {
                crit = crit.Add(Restrictions.Eq("ParentFolder.Id", id.Value));
            }
            else
            {
                crit = crit.Add(Restrictions.IsNull("ParentFolder"));
            }
            if (options != null)
            {
                SetFetchOptions(crit, options);
            }
            return(crit.List <Folder>());
        }
Ejemplo n.º 7
0
 protected virtual void SetupFilter(ICriteria crit, FolderFilter filter)
 {
     if (filter != null)
     {
         if (!string.IsNullOrEmpty(filter.Name))
         {
             crit.Add(Restrictions.Like("Name", filter.Name, MatchMode.Anywhere));
         }
         if (filter.CreationDate != null)
         {
             if (filter.CreationDate.From.HasValue)
             {
                 crit.Add(Restrictions.Ge("CreationDate", filter.CreationDate.From.Value));
             }
             if (filter.CreationDate.To.HasValue)
             {
                 crit.Add(Restrictions.Le("CreationDate", filter.CreationDate.To.Value));
             }
         }
     }
 }
Ejemplo n.º 8
0
        public IEnumerable <FolderDto> GetFolders([FromQuery] FolderFilter input)
        {
            var result = folderService.GetFolders(input);

            return(result);
        }