예제 #1
0
        public async Task <ActionResult <IList <CallbackData> > > GetCallbackListAsync(GetCallbackListRequest request)
        {
            try
            {
                _ = request.DateFrom ?? throw new ArgumentNullException(nameof(request.DateFrom));

                var contentItemList = await _repository.GetContentItemListAsync <CallbackInfo>(KnownContentType.Callback, request.DateFrom, request.Published, false);

                if (contentItemList == null || contentItemList.Count == 0)
                {
                    return(Array.Empty <CallbackData>());
                }

                var contentDiff = contentItemList
                                  .GroupBy(x => x.Content.Callback.ContentItemId.Text)
                                  .Select(
                    x =>
                    x.OrderBy(y => y.Content.ModifiedUtc)
                    .LastOrDefault()
                    ?.Content.ToInterface()
                    )
                                  .Where(x => x != null)
                                  .ToArray();

                return(contentDiff);
            }
            catch (ArgumentNullException exception)
            {
                _logger.LogError($"ContentController:Error; {exception.Message}");
                return(BadRequest($"missing required parameter: {exception.ParamName}"));
            }
        }
예제 #2
0
        public async Task <ActionResult <IList <ContentItemIndex <object> > > > GetContentItemListAsync(GetContentItemListRequest request)
        {
            try
            {
                _ = request.ContentType ?? throw new ArgumentNullException(nameof(request.ContentType));

                var contentItemList = await _repository.GetContentItemListAsync <object>(request.ContentType, request.DateFrom, request.Published, request.IsDeleted);

                if (contentItemList == null || contentItemList.Count == 0)
                {
                    return(NotFound());
                }

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