private PatientIndexViewModel GetPatientIndexViewModelList() { var patientIndexViewModel = new PatientIndexViewModel(); var patientList = new List <PatientViewModel>(); patientList.Add(new PatientViewModel() { Id = 1, Name = "Max", FirstName = "Mustermann", DateOfBirth = DateTime.Today.AddDays(-32), Age = new Age(DateTime.Today.AddDays(-32)) }); patientList.Add(new PatientViewModel() { Id = 2, Name = "Herpich", FirstName = "Walter", DateOfBirth = DateTime.Today.AddDays(-39), Age = new Age(DateTime.Today.AddDays(-39)) }); patientList.Add(new PatientViewModel() { Id = 3, Name = "John", FirstName = "Rambo", DateOfBirth = DateTime.Today.AddDays(-24), Age = new Age(DateTime.Today.AddDays(-24)) }); var patient = new PatientViewModel() { Id = 1, Name = "Max", FirstName = "Mustermann", DateOfBirth = DateTime.Today.AddDays(-32), Age = new Age(DateTime.Today.AddDays(-32)) }; patientIndexViewModel.PatientItems = patientList; return(patientIndexViewModel); }
public async Task <PatientIndexViewModel> GetPatientItems() { try { //_logger.LogInformation("GetCatalogItems called."); var patients = await _patientService.GetPatientItems(); var patientViewModelList = _mapper.Map <List <Patient>, List <PatientViewModel> >(patients); PatientIndexViewModel patientIndexViewModel = new PatientIndexViewModel(); patientIndexViewModel.PatientItems = patientViewModelList; return(patientIndexViewModel); } catch (Exception exp) { Console.WriteLine(exp); throw (exp); } }
// GET: Patients public async Task <IActionResult> Index(string recherchePatient) { var patients = await _context.Patient.OrderBy(p => p.Numero).ToListAsync(); //from p in _context.Patient select p; foreach (var p in patients) { p.LesSuivis = await _context.Suivi.Where(x => x.Patient == p).ToListAsync(); } //Gestion de la barre de recherche if (!string.IsNullOrEmpty(recherchePatient)) { patients = patients.Where(p => (p.Numero).ToString().Contains(recherchePatient)).ToList(); } PatientIndexViewModel patientRecherche = new PatientIndexViewModel { Patients = patients, }; return(View(patientRecherche)); }