public async Task <PatientPage> GetPatients(FindPatientModel model, int limit, int skip) { try { List <Patient> collection; if (!String.IsNullOrWhiteSpace(model.PatientId)) { collection = await _patients.Find(p => p.PatientId == model.PatientId) .Skip(skip) .Limit(limit) .ToListAsync(); } else { collection = await _patients.Find(p => p.Name == model.Name).ToListAsync(); } var patientPage = new PatientPage { Patients = collection.ConvertToDTOExtension().ToList(), Count = Convert.ToInt32(await _patients.CountAsync(new BsonDocument())) }; return(patientPage); } catch (Exception e) { Debug.WriteLine(e.Message); return(null); } }
public async Task <IHttpActionResult> GetPatients([FromBody] FindPatientModel model) { try { IEnumerable <PatientDTO> patients = await _manager.GetPatients(model); return(patients.Count() > 0 ? Json(patients) : (IHttpActionResult)BadRequest("no patients found!")); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IEnumerable <PatientDTO> > GetPatients(FindPatientModel model) { List <Patient> collection; if (!String.IsNullOrWhiteSpace(model.PatientId)) { collection = await _patients.Find(p => p.PatientId == model.PatientId).ToListAsync(); } else { collection = await _patients.Find(p => p.Name == model.Name).ToListAsync(); } return(collection.ConvertToDTOExtension().ToList()); }
public Task <PatientPage> GetPatients(FindPatientModel model) { return(_pRep.GetPatients(model, 1, 0)); }
public Task <IEnumerable <PatientDTO> > GetPatients(FindPatientModel model) { return(_pRep.GetPatients(model)); }