Example #1
0
        public async Task <ActionResult <IEnumerable <MessageOption> > > GetOptions(
            [FromQuery] string filter, [FromQuery] string sort, [FromQuery] string range)
        {
            var filterParam = FilterParam.ParseParam(filter);
            var sortParam   = SortParam.ParseParam(sort);
            var rangeParam  = RangeParam.ParseParam(range);
            var query       = _context.MessageOptions
                              .AsQueryable()
                              .Filter(filterParam);
            var total = await query.CountAsync();

            var rst = await query.OrderBy(sortParam).Range(rangeParam).ToListAsync();

            Response.Headers.AddContentRange("MessageOptions", rangeParam, total, rst.Count);
            return(rst);
        }
Example #2
0
        public async Task <ActionResult <IEnumerable <Message> > > GetMessages(
            [FromQuery] string sort, [FromQuery] string range, [FromQuery] string filter
            )
        {
            var sortParam   = SortParam.ParseParam(sort);
            var rangeParam  = RangeParam.ParseParam(range);
            var filterParam = FilterParam.ParseParam(filter);
            var query       = Messages.Filter(filterParam);
            var totalCount  = await query.CountAsync();

            query = query.OrderBy(sortParam).Range(rangeParam);
            var rst = await query.AsNoTracking().ToListAsync();

            Response.Headers.AddContentRange("StaticMessages", rangeParam, totalCount, rst.Count);
            Response.Headers.Add("Access-Control-Expose-Headers", "Content-Range");
            return(rst);
        }
Example #3
0
        public async Task <ActionResult <IEnumerable <Question> > > GetQuestions(
            [FromQuery] string sort, [FromQuery] string range, [FromQuery] string filter)
        {
            var sortParam   = SortParam.ParseParam(sort);
            var rangeParam  = RangeParam.ParseParam(range);
            var filterParam = FilterParam.ParseParam(filter);
            var query       = _context.Questions.Where(q => !q.Deleted).AsQueryable();

            query = query.Filter(filterParam);
            var totalEntryCount = await query.CountAsync();

            var topicList = await query.OrderBy(sortParam).Range(rangeParam).AsNoTracking().ToListAsync();

            var count = topicList.Count;

            Response.Headers.AddContentRange("Questions", rangeParam, totalEntryCount, count);
            Response.Headers.Add("Access-Control-Expose-Headers", "Content-Range");
            return(topicList);
        }