Exemplo n.º 1
0
        static public Shared.Folder ToSharedFolder(this Entities.Folder model)
        {
            var folder = new Shared.Folder()
            {
                Id              = model.Id,
                Name            = model.Name,
                AuthorizedUsers = model.AuthorizedUsers.Select(a => a.ToSharedAuthorizedUser()).ToList()
            };

            return(folder);
        }
Exemplo n.º 2
0
 FileSystemObject MapToDto(Entities.Folder folder, int?depth)
 {
     return(new DirectoryDto()
     {
         Path = _pathHelper.PathToUrl(folder.Path),
         ApiPath = _pathHelper.PathToUrl(_pathHelper.GetApiPath(folder.Path)),
         Name = folder.Name,
         HasSubdirectories = folder.Children.Any(),
         Children = depth == 0
             ? null
             : folder.Children.OrderBy(x => x.Name)
                    .Select(x => MapToDto(x, depth - 1))
                    .Union(
             folder.Files.OrderBy(x => x.OriginalCreationTime ?? x.ModificationTimestamp)
             .Select(MapToDto)
             )
                    .ToList()
     });
 }
Exemplo n.º 3
0
        public override Message ReciveStringData(string data)
        {
            var folder = new Entities.Folder()
            {
                UserId           = _client.ChatId, Name = data,
                PreviousFolderId = PreviousFolderId
            };
            int        folderID  = _client.AspNetAPI.CreateUserFolder(folder).Result;
            BaseFolder newFolder = new UserFolder(folderID, _currentFolder.Id, folder.Name);

            // TODO create a folder factory
            newFolder.AddTransition("/create", new CreateCommand(_client, newFolder));
            newFolder.AddTransition(newFolder.CommandToReturnFromFolder, _currentFolder);
            _currentFolder.AddTransition($"/{folder.Name}", newFolder);
            _client.SetFolder(_currentFolder);
            return(new Message()
            {
                Text = "Folder created"
            });
        }
Exemplo n.º 4
0
        public int AddFolder(Folder folder)
        {
            var user = _dbContext.Users.SingleOrDefault(x => x.Id == folder.UserId);

            var parentFolder = folder.FolderId == null
                ? null
                : _dbContext.Folders.SingleOrDefault(x => x.Id == folder.FolderId);

            var entity = new Entities.Folder()
            {
                Name   = folder.Name,
                Guid   = folder.Guid,
                User   = user,
                Folder = parentFolder,
            };

            _dbContext.Folders.Add(entity);
            _dbContext.SaveChanges();

            return(entity.Id);
        }
Exemplo n.º 5
0
        async public Task<IActionResult> CreateFolder([FromBody] ghostlight.Shared.Folder model)
        {
            string userEmail = User.GetUserEmail();

            Entities.Folder folder = new Entities.Folder()
            {
                Name = model.Name,
                AuthorizedUsers = new List<Entities.AuthorizedUser>()
                {
                    new Entities.AuthorizedUser()
                    {
                        Email = userEmail,
                        Administrator = true,
                        Write = true,
                        Read = true,
                        Delete = true
                    }
                }
            };
            _db.Folders.Add(folder);
            await _db.SaveChangesAsync();

            return Ok(folder.ToSharedFolder());
        }