コード例 #1
0
        public async Task <IActionResult> GetDocument(string dbname, string index, string id)
        {
            if (await UserService.CheckAuthorize(Request, false, dbname) is null)
            {
                return(Unauthorized(ErrorDto.GetAuthError()));
            }
            if (Guid.TryParse(id, out var guid))
            {
                var result = await DatabaseService.FindById(new IndexModel(dbname, index), guid);

                if (result is null)
                {
                    return(NoContent());
                }
                return(Ok(DocumentMapper.MapToDto(result)));
            }

            return(BadRequest(new ErrorDto(ErrorsType.SyntaxError, $"{id} is not GUID")));
        }