public TableResultJson <LoggingViewModel> GetPaged(TableRequest request) { var dataSource = loggingRepository.GetAll().OrderByDescending(x => x.CreatedDate.Value).AsEnumerable(); if (request.columns[0].search != null) { if (!string.IsNullOrEmpty(request.columns[0].search.value)) { dataSource = dataSource.Where(x => x.RequestMethod.Contains(request.columns[0].search.value)); } } if (request.columns[1].search != null) { if (!string.IsNullOrEmpty(request.columns[1].search.value)) { dataSource = dataSource.Where(x => x.Location.Contains(request.columns[1].search.value)); } } if (request.columns[3].search != null) { if (!string.IsNullOrEmpty(request.columns[3].search.value)) { dataSource = dataSource.Where(x => x.StatusCode.ToString().Contains(request.columns[3].search.value)); } } var response = new TableResultJson <LoggingViewModel>(); response.draw = request.draw; response.recordsFiltered = dataSource.Count(); dataSource = dataSource.Skip(request.start).Take(request.length); response.data = mapper.Map <List <LoggingViewModel> >(dataSource.ToList()); foreach (LoggingViewModel item in response.data) { item.Index = response.data.IndexOf(item) + request.start + 1; } return(response); }