/// <summary> /// Get family details list /// </summary> /// <param name="userid"></param> /// <returns></returns> private IPagedList <FamilyHistory> FamilyDetailsPagedList(int userid) { List <EmployeeFamilyDetail> list = _IFamilyDetailsService.GetEmployeeFamilyDetailsByUserID(userid); var genderlist = GetGenderList(); var dependentlist = GetDependentList(); var countryCodeList = GetCountryCode(); List <Master_Relation> relationShipList = _IRelationService.GetAll(null, null, "").ToList(); List <FamilyHistory> ModelList = new List <FamilyHistory>(); int id = 0; ModelList = list .Select(x => new FamilyHistory() { ID = 0, FamDetID = x.FamDetID, //FullName = x.FullName, FirstName = x.FirstName, LastName = x.LastName, DOB = x.DOB.HasValue ? x.DOB.Value.ToShortDateString() : string.Empty, Gender = (x.Gender != null) ? genderlist.SingleOrDefault(s => s.Text == x.Gender).Text : string.Empty, IsActive = x.IsActive.ToString(), RelationShipName = relationShipList.SingleOrDefault(s => s.RelationID == x.RelationshipID).RelationName, Dependent = (x.Dependent != null) ? dependentlist.SingleOrDefault(s => s.Value == x.Dependent).Text : string.Empty, RelationshipID = x.RelationshipID, UserID = x.UserID, CountryCode = x.CountryCode, ContactNumber = x.ContactNumber, IsEmergencyContact = x.IsEmergencyContact.HasValue ? x.IsEmergencyContact.Value : false }) .ToList(); var personalDetails = _IPersonalService.GetPersonalDetailsByUserId(userId); if (personalDetails != null && personalDetails.MaritalStatID == Constants.Single) { ModelList = ModelList.Where(m => m.RelationshipID != Constants.Child).ToList(); ModelList = ModelList.Where(m => m.RelationshipID != Constants.Spouse).ToList(); } int pageSize = 10; //not required int pageIndex = 1; //not required foreach (var item in ModelList) { item.ID = id + 1; id = item.ID; } return(ModelList.ToPagedList(pageIndex, pageSize)); }