public int Add(Patient patient) { int returnValue = -1; try { using (var db = new Models.ObalonEntities()) { if (patient.DoctorId == 0) { patient.DoctorId = 77777; } db.Patients.Add(patient); db.SaveChanges(); returnValue = patient.PatientId; } } catch (Exception ex) { //logger.Error("Error while calling GetPatients", ex); } return(returnValue); }
public bool Save(Event evt) { try { using (var db = new Models.ObalonEntities()) { db.Events.Add(evt); db.SaveChanges(); } return(true); } catch (System.Exception ex) { return(false); } }
public ResponseItemList <Event> GetEvents(int patientId) { ResponseItemList <Event> returnValue = new Utils.ResponseItemList <Event>(); try { using (var db = new Models.ObalonEntities()) { returnValue.Items = db.Events.Include("EventType").Where(ev => ev.PatientId == patientId).OrderByDescending(ev => ev.EventId).ToList(); // (from ev in db.Events where ev.PatientId == pacientId select ev).ToList(); returnValue.TotalRecords = returnValue.Items.Count; } } catch (System.Exception ex) { } return(returnValue); }
public ResponseItemList <Patient> GetPatients(int doctorId) { ResponseItemList <Patient> returnValue = new Utils.ResponseItemList <Models.Patient>(); try { using (var db = new Models.ObalonEntities()) { returnValue.Items = db.Patients.Where(p => p.DoctorId == doctorId).OrderByDescending(p => p.PatientId).ToList(); returnValue.TotalRecords = returnValue.Items.Count; } } catch (Exception ex) { //logger.Error("Error while calling GetPatients", ex); } return(returnValue); }