public async Task <IActionResult> Search(string searchString) { ViewBag.Action = "Home"; ViewData["CurrentFilter"] = searchString; List <Doctor> doctors = await _context.PatientDoctors .Where(pd => pd.Patient.Id.Equals(_activeUser.Id) && (pd.Doctor.User.FirstName.Contains(searchString) || pd.Doctor.User.LastName.Contains(searchString) || pd.Doctor.User.LastName.Contains(searchString))) .Select(pd => pd.Doctor) .Include(pd => pd.User) .ToListAsync(); List <Appointment> appointments = await _context.Appointments .Where(p => p.Patient.User.UserName.Equals(_activeUser.UserName)) .ToListAsync(); PatientHomeViewModel patientHomeViewModel = new PatientHomeViewModel() { Doctors = doctors, Appointments = appointments }; return(View("Index", patientHomeViewModel)); }
public async Task <IActionResult> Index() { ViewBag.Action = "Home"; List <Doctor> doctors = await _context.PatientDoctors .Where(pd => pd.Patient.User.UserName.Equals(_activeUser.UserName)) .Select(pd => pd.Doctor) .Include(pd => pd.User) .ToListAsync(); List <Appointment> appointments = await _context.Appointments .Where(p => p.Patient.User.UserName.Equals(_activeUser.UserName)) .ToListAsync(); PatientHomeViewModel patientHomeViewModel = new PatientHomeViewModel() { Doctors = doctors, Appointments = appointments }; return(View(patientHomeViewModel)); }