예제 #1
0
        public SqlDirectory CreateDirectory(SqlDirectory parent, string name)
        {
            if (GetDirectories(parent).Any(x => x.Name.Matches(name)))
                throw new FileSystemException(string.Format("Directory with the name [{0}] already exists.", name));

            var directory = directoryRepository.Create();
            directory.ParentDirectory = parent;
            directory.IsDeleted = false;
            directory.IsRoot = false;
            directory.Name = name;

            if (!directoryRepository.Save(directory, true))
                throw new FileSystemException("Failed to save new directory.");
            return directory;
        }
예제 #2
0
 public IList<SqlDirectory> GetDirectories(SqlDirectory directory)
 {
     var predicate = new PredicateExpression()
             .Where<SqlDirectory>(x => x.ParentDirectory).IsEqualTo(directory.Id)
             .And<SqlDirectory>(x => x.IsDeleted).IsEqualTo(false)
             .And<SqlDirectory>(x => x.IsRoot).IsEqualTo(0);
     return directoryRepository.FetchAll(predicate);
 }