public GetDoctorResponse GetDoctor(int id) { if (!_context.Doctors.Any()) { return(null); } var doc = _context.Doctors.Where(d => d.IdDoctor.Equals(id)).FirstOrDefault(); var response = new GetDoctorResponse { FirstName = doc.FirstName, LastName = doc.LastName, Email = doc.Email }; return(response); }
public GetDoctorResponse getById(int id) { try { var response = new GetDoctorResponse(); var bc = new DoctorComponent(); response.Result = bc.Find(id); return(response); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }
public IEnumerable <GetDoctorResponse> GetAllDoctors() { if (!_context.Doctors.Any()) { return(null); } List <GetDoctorResponse> responseList = new List <GetDoctorResponse>(); foreach (Doctor d in _context.Doctors) { var response = new GetDoctorResponse { FirstName = d.FirstName, LastName = d.LastName, Email = d.Email }; responseList.Add(response); } return(responseList); }