О «Ничьей» по отношению к таблице данных

#c# #datatables #datatables-1.10

Вопрос:

Я не понимаю инструкцию «рисовать».

Как я должен получить данные для «рисования» по отношению к возвращенным данным?

(https://datatables.net/manual/server-side#Sent-parameters)

Спасибо!

 using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using RestSharp;
using RestSharp.Authenticators;
using Newtonsoft.Json;


namespace CloudTableApi.Controllers

{
    [ApiController]
    [Route("api/[controller]")]
    public class TestsController : ControllerBase
    {
        /// <summary> 
        /// https://localhost:44340/api/Tests/ 
        /// </summary> 
        /// <returns></returns> 
        [HttpGet("GetAllPosts")]
        public Info GetAllPosts()
        {
            var client = new RestClient("https://jsonplaceholder.typicode.com/");
            var request = new RestRequest("comments", DataFormat.Json);
            var response = client.Get(request);

            List<Comment> m = JsonConvert.DeserializeObject<List<Comment>>(response.Content);

            Info my = new Info();
            my.Data = m;

            return my;
        }


        /// <summary> 
        /// https://localhost:44340/api/Tests/SimpleGetAllPostsByPagenumber?pagenumber=1 
        /// </summary> 
        /// <param name="pagenumber"></param> 
        /// <returns></returns> 
        [HttpGet("SimpleGetAllPostsByPagenumber")]
        public List<Comment> SimpleGetAllPostsByPagenumber(int pagenumber)
        {
            var clientAllData = new RestClient("https://jsonplaceholder.typicode.com/");
            var requestAllData = new RestRequest("comments", DataFormat.Json);
            var responseAllData = clientAllData.Get(requestAllData);

            List<Comment> datawithpagenumberAllData = JsonConvert.DeserializeObject<List<Comment>>(responseAllData.Content);


            //---------- 

            var client = new RestClient("https://jsonplaceholder.typicode.com/");
            var request = new RestRequest("comments?postId="   pagenumber.ToString(), DataFormat.Json);
            var response = client.Get(request);
            List<Comment> datawithpagenumber = JsonConvert.DeserializeObject<List<Comment>>(response.Content);

            //---------- 



            /* 

            Info info = new Info(); 

            info.Data = datawithpagenumber; 

            info.TotalRecords = datawithpagenumberAllData.Count(); 

            info.TotalDisplayRecords = datawithpagenumber.Count(); 

            */


            return datawithpagenumber;
        }


        /// <summary> 
        /// https://localhost:44340/api/Tests/GetAllPostsByPagenumber?pagenumber=1 
        /// </summary> 
        /// <param name="pagenumber"></param> 
        /// <returns></returns> 
        [HttpGet("GetAllPostsByPagenumber")]
        public Info GetAllPostsByPagenumber(int pagenumber)
        {
            var clientAllData = new RestClient("https://jsonplaceholder.typicode.com/");
            var requestAllData = new RestRequest("comments", DataFormat.Json);
            var responseAllData = clientAllData.Get(requestAllData);

            List<Comment> datawithpagenumberAllData = JsonConvert.DeserializeObject<List<Comment>>(responseAllData.Content);



            //---------- 

            var client = new RestClient("https://jsonplaceholder.typicode.com/");
            var request = new RestRequest("comments?postId="   pagenumber.ToString(), DataFormat.Json);
            var response = client.Get(request);

            List<Comment> datawithpagenumber = JsonConvert.DeserializeObject<List<Comment>>(response.Content);

            //---------- 

            Info info = new Info();
            info.Data = datawithpagenumber;
            info.recordsTotal = datawithpagenumberAllData.Count();
            info.recordsFiltered = datawithpagenumber.Count();

            return info;
        }





    }


    public class Info
    {
        public int recordsTotal { get; set; }
        public int recordsFiltered { get; set; }
        public List<Comment> Data { get; set; }
    }


    public class Comment
    {
        public int PostId { get; set; }
        public int Id { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
        public string Body { get; set; }
    }

}
 

Комментарии:

1. Это не автоматическая машина или что-то в этом роде. Это человек за спиной, который просит о помощи!