Example #1
0
        public async Task <IActionResult> GetCheckpointAsync([FromRoute] string id, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (!Guid.TryParse(id, out var guid))
            {
                var error = ErrorResponsesService.NotFoundError(Target, $"Checkpoint with id '{id}' not found.");
                return(BadRequest(error));
            }

            Model.Checkpoint modelCheckpoint;

            try
            {
                modelCheckpoint = await repository.GetAsync(guid, cancellationToken).ConfigureAwait(false);
            }
            catch (CheckpointNotFoundException ex)
            {
                var error = ErrorResponsesService.NotFoundError(Target, ex.Message);
                return(NotFound(error));
            }

            var clientCheckpoint = Converter.CheckpointConverter.Convert(modelCheckpoint);

            return(Ok(clientCheckpoint));
        }