public async Task <JsonResult> Search(string query) { var patients = (await PatientFacade.GetAllPatientsAsync()).Items; var models = patients.Select(patient => new AddDoctorToPatientModel { Name = patient.Name + " " + patient.Surname }).Where(patient => patient.Name.Contains(query)); return(new JsonResult { Data = models, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public async Task <ActionResult> AddDoctorToPatient(AddDoctorToPatientModel model) { if (model.Name.IsNullOrEmpty()) { ModelState.AddModelError("Name", "Field cannot be empty"); return(View(model)); } var patients = (await PatientFacade.GetAllPatientsAsync()) .Items .Where(patient => (patient.Name + " " + patient.Surname).Contains(model.Name)) .ToList(); return(View("ShowPatientsForName", patients)); }