Beispiel #1
0
        public async Task <ActionResult <ContentItemIndex <object> > > GetContentItemByIdAsync(GetContentItemRequest request)
        {
            try
            {
                _ = request.Id ?? throw new ArgumentNullException(nameof(request.Id));
                _ = request.ContentType ?? throw new ArgumentNullException(nameof(request.ContentType));

                var contentItem = await _repository.GetContentItemByIdAsync <object>(request.ContentType, request.Id, request.Published);

                if (contentItem == null)
                {
                    return(NotFound());
                }

                return(Ok(contentItem));
            }
            catch (ArgumentNullException exception)
            {
                _logger.LogError($"ContentController:Error; {exception.Message}");
                return(BadRequest($"missing required parameter: {exception.ParamName}"));
            }
        }