Пример #1
0
        public HttpResponseMessage GetData(HttpRequestMessage request)
        {
            //System.Threading.Thread.Sleep(5000);

            string queryString = HttpUtility.UrlDecode(request.Content.ReadAsStringAsync().Result);
            var    data        = HttpUtility.ParseQueryString(queryString);
            int    filteredCount;
            var    requestData = DataTableRequest.Parse(data);
            var    people      = peopleService.GetPeople(
                requestData.Start,
                requestData.Length,
                requestData.Search.Value,
                requestData.GetFilters(),
                requestData.Order.ToDictionary(
                    o => o.Column,
                    o => o.Dir == DataTableOrderDirection.Asc ? 1 : -1),
                out filteredCount);
            var response = new DataTableResponse <Person>
            {
                Draw            = requestData.Draw,
                RecordsTotal    = peopleService.GetTotalPeople(),
                RecordsFiltered = filteredCount,
                DataItems       = people
            };

            return(request.CreateResponse(HttpStatusCode.OK, response));
        }
Пример #2
0
 internal static DataTableResult DataTableJson <T>(NameValueCollection request, List <T> list, Func <string, object, object> formatter, params Expression <Func <T, object> >[] col)
 {
     return(DataTableJson <T>(DataTableRequest.Parse(request), list, formatter, col));
 }