public DataTablesObject <AccountDto> GetAccountList(SearchFilters searchFilter) { var accountList = new List <AccountDto>(); var doctors = (from doctor in _context.Doctors select new AccountDto { RoleName = "Doktor", Name = doctor.FirstName, Surname = doctor.Surname, WardName = doctor.Ward.Name, PhoneNumber = doctor.PhoneNumber, IsActive = doctor.User.IsActive, UserId = doctor.User.Id }).ToList(); var nurses = (from nurse in _context.Nurses select new AccountDto { RoleName = "Pielęgniarka", Name = nurse.FirstName, Surname = nurse.Surname, WardName = nurse.Ward.Name, PhoneNumber = nurse.PhoneNumber, IsActive = nurse.User.IsActive, UserId = nurse.User.Id }).ToList(); accountList.AddRange(doctors); accountList.AddRange(nurses); var count = 1; accountList.ForEach(x => x.Id = count++); var outputList = accountList.OrderBy(searchFilter.OrderBy).Skip(searchFilter.DisplayStart) .Take(searchFilter.DisplayLength).ToList(); var postRequests = new DataTablesObject <AccountDto>(); postRequests.iTotalRecords = postRequests.iTotalDisplayRecords = accountList.Count; postRequests.aaData = outputList; return(postRequests); }
public DataTablesObject <PatientDto> GetPatientList(SearchFilters searchFilters) { var patients = (from patient in _context.Patients select new PatientDto { Id = patient.Id, FirstName = patient.FirstName, Surname = patient.Surname, Pesel = patient.Pesel, City = patient.Address.City, PhoneNumber = patient.PhoneNumber }).ToList(); var outputList = patients.OrderBy(searchFilters.OrderBy).Skip(searchFilters.DisplayStart) .Take(searchFilters.DisplayLength).ToList(); var postRequests = new DataTablesObject <PatientDto>(); postRequests.iTotalRecords = postRequests.iTotalDisplayRecords = patients.Count; postRequests.aaData = outputList; return(postRequests); }