diff options
| author | ivar <i@oiee.no> | 2024-03-19 01:02:22 +0100 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2024-03-19 01:02:22 +0100 |
| commit | 5f604b3052dab1d51dc130df2470bf330b283ec6 (patch) | |
| tree | ae00e1fe4542850467555b4e3af41964ba8d878b /code/api/Endpoints/Storage/TreeEndpoint.cs | |
| parent | 63cf177e8cf22e349534664d59a6926f8b36863d (diff) | |
| download | storage-5f604b3052dab1d51dc130df2470bf330b283ec6.tar.xz storage-5f604b3052dab1d51dc130df2470bf330b283ec6.zip | |
Max lenghts on db schema
Use latest temporal from cdn
Implement majority of translation functionality
Major refinements/bugs
Diffstat (limited to 'code/api/Endpoints/Storage/TreeEndpoint.cs')
| -rw-r--r-- | code/api/Endpoints/Storage/TreeEndpoint.cs | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/code/api/Endpoints/Storage/TreeEndpoint.cs b/code/api/Endpoints/Storage/TreeEndpoint.cs index f832034..df2ed5e 100644 --- a/code/api/Endpoints/Storage/TreeEndpoint.cs +++ b/code/api/Endpoints/Storage/TreeEndpoint.cs @@ -1,33 +1,26 @@ -namespace I2R.Storage.Api.Endpoints.Storage; +namespace Quality.Storage.Api.Endpoints.Storage; -public class TreeEndpoint : EndpointBase +public class TreeEndpoint(AppDatabase database, IPaginationService pagination) : EndpointBase { - private readonly AppDatabase _database; - private readonly IPaginationService _pagination; - - public TreeEndpoint(AppDatabase database, IPaginationService pagination) { - _database = database; - _pagination = pagination; - } - - [HttpGet("~/storage/tree")] - public async Task<ActionResult<KeysetPaginationResult<FileSystemEntry>>> Handle(Guid parent = default) { - return Ok(await _pagination.KeysetPaginateAsync( - _database.Folders.Include(c => c.Files).ConditionalWhere(() => parent != default, folder => folder.ParentId == parent), - b => b.Descending(a => a.Name), - async id => await _database.Folders.FirstOrDefaultAsync(c => c.Id == id.AsGuid()), - query => query.Select(p => new FileSystemEntry() { - Id = p.Id, - Name = p.Name, - MimeType = SystemConstants.FolderMimeType, - SizeInBytes = -1, - Files = p.Files.Select(c => new FileSystemEntry() { - Id = c.Id, - Name = c.Name, - MimeType = c.MimeType, - SizeInBytes = c.SizeInBytes - }).ToList() - }) - )); - } -}
\ No newline at end of file + [HttpGet("~/storage/tree")] + public async Task<ActionResult<KeysetPaginationResult<FileSystemEntry>>> Handle(Guid parent = default) { + return Ok(await pagination.KeysetPaginateAsync(database.Folders + .Include(c => c.Files) + .ConditionalWhere(() => parent != default, folder => folder.ParentId == parent), + b => b.Descending(a => a.Name), + async id => await database.Folders.FirstOrDefaultAsync(c => c.Id == id.AsGuid()), + query => query.Select(p => new FileSystemEntry { + Id = p.Id, + Name = p.Name, + MimeType = SystemConstants.FolderMimeType, + SizeInBytes = -1, + Files = p.Files.Select(c => new FileSystemEntry { + Id = c.Id, + Name = c.Name, + MimeType = c.MimeType, + SizeInBytes = c.SizeInBytes + }) + .ToList() + }))); + } +} |
