예제 #1
0
        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
            });
        }
예제 #2
0
        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));
        }