Пример #1
0
        public JsonResult GetAllCountry(DataTableAjaxPostModel model, CountryAdvanceSearchViewModel CountryAdvanceSearchVM)
        {
            CountryAdvanceSearchVM.DataTablePaging.Start  = model.start;
            CountryAdvanceSearchVM.DataTablePaging.Length = (CountryAdvanceSearchVM.DataTablePaging.Length == 0) ? model.length : CountryAdvanceSearchVM.DataTablePaging.Length;
            List <CountryViewModel> CountryVMList = Mapper.Map <List <Country>, List <CountryViewModel> >(_contryBusiness.GetAllCountry(Mapper.Map <CountryAdvanceSearchViewModel, CountryAdvanceSearch>(CountryAdvanceSearchVM)));

            if (CountryAdvanceSearchVM.DataTablePaging.Length == -1)
            {
                int totalResult    = CountryVMList.Count != 0 ? CountryVMList[0].TotalCount : 0;
                int filteredResult = CountryVMList.Count != 0 ? CountryVMList[0].FilteredCount : 0;
                CountryVMList = CountryVMList.Skip(0).Take(filteredResult > 10000 ? 10000 : filteredResult).ToList();
            }
            return(Json(new
            {
                // this is what datatables wants sending back
                draw = model.draw,
                recordsTotal = CountryVMList.Count != 0 ? CountryVMList[0].TotalCount : 0,
                recordsFiltered = CountryVMList.Count != 0 ? CountryVMList[0].FilteredCount : 0,
                data = CountryVMList
            }));
        }