示例#1
0
        //[ResponseCache(CacheProfileName = "Collection")]
        public async Task <ActionResult <Collection <Question> > > GetAllQuestionsByFeedbackType(
            [FromQuery] PagingOptions pagingOptions,
            [FromQuery] SortOptions <Question, QuestionEntity> sortOptions,
            [FromQuery] SearchOptions <Question, QuestionEntity> searchOptions,
            [FromRoute] string feedbackType,
            CancellationToken ct)
        {
            pagingOptions.Offset = pagingOptions.Offset ?? _defaultPagingOptions.Offset;
            pagingOptions.Limit  = pagingOptions.Limit ?? _defaultPagingOptions.Limit;

            var questions = await _feedback.GetAllByFeedbackTypeAsync(pagingOptions, sortOptions, searchOptions, feedbackType, ct);

            var collection = PagedCollection <Question> .Create <QuestionResponse>(
                Link.ToCollection(nameof(GetAllQuestionsByFeedbackType)),
                questions.Items.ToArray(),
                questions.TotalSize,
                pagingOptions);

            //TODO
            //collection.Answers = Link.ToCollection(nameof(AnswersController.GetItem));
            collection.QuestionForm = FormMetadata.FromModel(
                new QuestionForm(),
                Link.ToForm(nameof(QuestionsController.CreateQuestion),
                            null, relations: Form.Relation));
            collection.QuestionsQuery = FormMetadata.FromResource <Question>(
                Link.ToForm(
                    nameof(GetAllQuestionsByFeedbackType),
                    null,
                    Link.GetMethod,
                    Form.QueryRelation));

            return(collection);
        }