Пример #1
0
        public async Task <IActionResult> GetContainer([FromQuery] string containername)
        {
            var query  = new GetContainerQuery(containername);
            var result = await _mediator.Send(query);

            return(ResultResponse(result));
        }
Пример #2
0
        public Task <Result <CabinetFileInfo> > Handle(GetContainerQuery request, CancellationToken cancellationToken)
        {
            return(Task.Run(() =>
            {
                var path = Path.Combine(cs.DataDir, request.ContainerName);
                if (!Directory.Exists(path))
                {
                    var message = $"container name '{request.ContainerName}' does not exist";
                    return Result.Fail <CabinetFileInfo>(new Error(message));
                }

                var dir = new DirectoryInfo(path);
                // use auto mapper
                var cfInfo = new CabinetFileInfo {
                    CreatedAt = dir.CreationTime, Name = dir.Name, Path = dir.FullName
                };

                return Result.Ok(cfInfo);
            }));
        }