Пример #1
0
        /// <inheritdoc/>
        public Task <ContinentViewModel> Handle(GetContinentByIdQuery request, CancellationToken cancellationToken)
        {
            var requestId = request.Id;

            return(_repository.GetContinentById(requestId)
                   .ContinueWith(fetchTask =>
            {
                GuardAgainst.FaultedOrCancelled(fetchTask);
                var model = fetchTask.Result;
                if (model == null)
                {
                    throw new NotFoundException($"{nameof(requestId)} not found");
                }
                return _mapper.Map <ContinentViewModel>(model);
            }, cancellationToken));
        }