public async Task <JsonResult> GetAllLearners() { try { var draw = HttpContext.Request.Query["draw"].FirstOrDefault(); // Skiping number of Rows count var start = Request.Query["start"].FirstOrDefault(); // Paging Length 10,20 var length = Request.Query["length"].FirstOrDefault(); // Sort Column Name var sortColumn = Request .Query["columns[" + Request.Query["order[0][column]"].FirstOrDefault() + "][name]"] .FirstOrDefault(); // Sort Column Direction ( asc ,desc) var sortColumnDirection = Request.Query["order[0][dir]"].FirstOrDefault(); // Search Value from (Search box) var searchValue = Request.Query["search[value]"].FirstOrDefault(); //Paging Size (10,20,50,100) var pageSize = length != null?Convert.ToInt32(length) : 0; var skip = start != null?Convert.ToInt32(start) : 0; var recordsTotal = 0; var listOfLearners = await _lookUpService.GetAllLearners().ConfigureAwait(false); listOfLearners = listOfLearners.Where(l => !l.AppliedYn.Equals(Const.TRUE)).ToList(); // Getting all Customer data z var allLearners = listOfLearners.Select(a => new LearnerDetailsDto() { LearnerId = a.LearnerId, Email = a.Person.Email, FirstName = a.Person.FirstName, LastName = a.Person.LastName, PersonsDob = a.Person.PersonsDob.ToString(Const.DATE_FORMAT), GenderName = a.Person.Gender.GenderDesc, EquityName = a.Person.Equity.EquityDesc, HomeLanguage = a.Person.HomeLanguage.HomeLanguageDesc, DisabilityStatus = a.Person.DisabilityStatus.DisabilityStatusDesc, CitizenshipStatus = a.Person.CitizenshipStatus.CitizenshipStatusDesc, PhoneNumber = a.Person.PhoneNumber, Age = Utils.CalculateAge(a.Person.PersonsDob), Nationality = a.Person.Nationality.NationalityDesc, NationalID = a.Person.NationalId, HouseNo = a.Person.Address.ToList()[0].HouseNo, StreetName = a.Person.Address.ToList()[0].StreetName, SuburbName = a.Person.Address.ToList()[0].Suburb.SuburbName, CityName = a.Person.Address.ToList()[0].City.CityName, ProvinceName = a.Person.Address.ToList()[0].Province.ProvinceName, CountryName = a.Person.Address.ToList()[0].Country.CountryName, AddressType = a.Person.Address.ToList()[0].AddressType.AddressTypeName, PostalCode = a.Person.Address.ToList()[0].PostalCode, SchoolName = a.School.SchoolName, SchoolGradeName = a.SchoolGrade.SchoolGradeName, YearSchoolCompleted = a.YearSchoolCompleted.ToString(Const.DATE_FORMAT), RecruitedYn = a.RecruitedYn, AppliedYn = a.AppliedYn, PhotoName = a.Person.PhotoName, PhotoPath = a.Person.PhotoPath, Qualifications = a.LearnerCourse.Select(qualification => new QualificationDTO() { Id = qualification.LearnerCourseId, CourseName = qualification.CourseName, InstitutionName = qualification.InstitutionName, DateOfCompletion = qualification.DateOfCompletion }) as List <QualificationDTO>, }).ToList(); //Search if (!string.IsNullOrEmpty(searchValue)) { allLearners = allLearners.Where(m => m.FirstName.Equals(searchValue) || m.LastName.Equals(searchValue) || m.NationalID.Equals(searchValue)) as List <LearnerDetailsDto>; } //total number of rows count recordsTotal = allLearners.Count(); //Paging var dataList = allLearners.Skip(skip).Take(pageSize).ToList(); //Returning Json Data return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = allLearners })); } catch (Exception) { throw; } }