public bool DeleteAppointment(ref AppointmentBDO app, ref string message) { message = "Doctor deleted successfully"; var ret = true; using (var PHEntities = new PublicHospitalEntities()) { var appId = app.id; var appointmentInDb = (from a in PHEntities.Appointment where a.id == appId select a).FirstOrDefault(); if (appointmentInDb != null) { PHEntities.Appointment.Remove(appointmentInDb); var num = PHEntities.SaveChanges(); if (num != 1) { ret = false; } } else { ret = false; message = "Appointment not found"; } return ret; } }
public bool DeleteAppointment(ref Appointment appointment, ref string message) { AppointmentBDO app = new AppointmentBDO(); TranslateAppointmentDTOToAppointmentBDO(appointment,app); bool ret = false; try { ret = AppointmentLogic.DeleteAppointment(ref app, ref message); } catch (Exception e) { var msg = e.Message; var reason = "DeleteAppointment exception"; throw new FaultException<AppointmentFault> (new AppointmentFault(msg), reason); } return ret; }
public bool UpdateAppointment( ref AppointmentBDO appointmentBDO, ref string message) { var appointmentInDb = GetAppointment(appointmentBDO.id); if (appointmentInDb == null) { message = "cannot fetch appointment with this ID"; return false; } else { return appointmentDAO.Updateappointment(ref appointmentBDO, ref message); } }
public bool InsertAppointment(ref AppointmentBDO appointmentBDO, ref string massage) { return appointmentDAO.InsertAppointment(ref appointmentBDO, ref massage); }
public bool DeleteAppointment(ref AppointmentBDO app, ref string message) { return appointmentDAO.DeleteAppointment(ref app,ref message); }
private void TranslateAppointmentDTOToAppointmentBDO( Appointment Appointment, AppointmentBDO AppointmentBDO) { DoctorBDO doctorBDO = new DoctorBDO(); new DoctorService().TranslateDoctorDTOToDoctorBDO(Appointment.doctor, doctorBDO); PatientBDO patientBDO = new PatientBDO(); new PatientService().TranslatePatientDTOToPatientBDO(Appointment.patient, patientBDO); AppointmentBDO.id = Appointment.id; AppointmentBDO.patient = patientBDO; AppointmentBDO.serviceType = Appointment.serviceType; AppointmentBDO.time = Appointment.time; AppointmentBDO.doctor = doctorBDO; AppointmentBDO.rowVersion = Appointment.RowVersion; }
public bool UpdateAppointment(ref Appointment Appointment, ref string message) { var result = true; if (!AppointmentCheck(ref Appointment, ref message)) { result = false; } else { try { var AppointmentBDO = new AppointmentBDO(); TranslateAppointmentDTOToAppointmentBDO(Appointment, AppointmentBDO); result = AppointmentLogic.UpdateAppointment( ref AppointmentBDO, ref message); Appointment.RowVersion = AppointmentBDO.rowVersion; } catch (Exception e) { var msg = e.Message; throw new FaultException<AppointmentFault> (new AppointmentFault(msg), msg); } } return result; }
public bool SaveAppointment(ref Appointment appointment, ref string message) { var result = true; if (!AppointmentCheck(ref appointment, ref message)) { result = false; } else { try { var appointmentBDO = new AppointmentBDO(); TranslateAppointmentDTOToAppointmentBDO(appointment, appointmentBDO); result = AppointmentLogic.InsertAppointment( ref appointmentBDO, ref message); } catch (Exception e) { var msg = e.Message; throw new FaultException<AppointmentFault> (new AppointmentFault(msg), msg); } } return result; }
public List<AppointmentBDO> GetAllAppointments() { List<AppointmentBDO> appointments = null; AppointmentBDO appointmentBDO = null; PatientBDO patientBDO = null; DoctorBDO doctorBDO = null; using (var PHEntities = new PublicHospitalEntities()) { var listInDb = (from Appointment in PHEntities.Appointment from Doctor in PHEntities.Doctor from Patient in PHEntities.Patient where Appointment.idDoctor == Doctor.id && Appointment.idPatient == Patient.id select new { Appointment.id, Appointment.time, Appointment.serviceType, Doctor.firstName, Doctor.lastName, DoctorId = Doctor.id, Column1 = Patient.firstName, Column2 = Patient.lastName, Column3 = Patient.id }); if (listInDb != null) { appointments = new List<AppointmentBDO>(); foreach (var mergedList in listInDb) { if (mergedList != null) { doctorBDO = new DoctorBDO(); patientBDO = new PatientBDO(); doctorBDO.firstName = mergedList.firstName; doctorBDO.lastName = mergedList.lastName; doctorBDO.id = mergedList.DoctorId; patientBDO.firstName = mergedList.Column1; patientBDO.lastName = mergedList.Column2; patientBDO.id = mergedList.Column3; appointmentBDO = new AppointmentBDO() { id = mergedList.id, time = mergedList.time, serviceType = mergedList.serviceType, doctor = doctorBDO, patient = patientBDO }; appointments.Add(appointmentBDO); } } } } return appointments; }
public bool Updateappointment(ref AppointmentBDO appointmentBDO, ref string massage) { massage = "appointment updated successfully"; var ret = true; using (var PHEntites = new PublicHospitalEntities()) { var appointmentId = appointmentBDO.id; var appointmentInDb = (from a in PHEntites.Appointment where a.id == appointmentId select a).FirstOrDefault(); if (appointmentInDb == null) { throw new Exception("No appointment with id " + appointmentBDO.id); } appointmentInDb.id = appointmentBDO.id; appointmentInDb.time = appointmentBDO.time.Date; appointmentInDb.serviceType = appointmentBDO.serviceType; appointmentInDb.idPatient = appointmentBDO.patient.id; appointmentInDb.idDoctor = appointmentBDO.patient.id; appointmentInDb.rowVersion = appointmentBDO.rowVersion; PHEntites.Appointment.Attach(appointmentInDb); PHEntites.Entry(appointmentInDb).State = System.Data.Entity.EntityState.Modified; var num = PHEntites.SaveChanges(); appointmentBDO.rowVersion = appointmentInDb.rowVersion; if (num != 1) { ret = false; massage = "appointment was not updated"; } } return ret; }
public bool InsertAppointment(ref AppointmentBDO appointmentBDO, ref string massage) { massage = "Appointment inserted successfully"; var ret = true; using (var PHEntities = new PublicHospitalEntities()) { PHEntities.Appointment.Add(new Appointment { id = appointmentBDO.id, time = appointmentBDO.time, serviceType = appointmentBDO.serviceType, idPatient = appointmentBDO.patient.id, idDoctor = appointmentBDO.doctor.id, rowVersion = appointmentBDO.rowVersion }); var num = PHEntities.SaveChanges(); if (num != 1) { ret = false; massage = "Appointment was not inserted"; } } return ret; }
public AppointmentBDO GetAppointment(int id) { AppointmentBDO appointmentBDO = null; using (var PHEntities = new PublicHospitalEntities()) { var appointmentObj = (from a in PHEntities.Appointment where a.id == id select a).FirstOrDefault(); if (appointmentObj != null) { patientDAO = new PatientDAO(); doctorDAO = new DoctorDAO(); appointmentBDO = new AppointmentBDO() { id = appointmentObj.id, time = Convert.ToDateTime(appointmentObj.time), serviceType = appointmentObj.serviceType, patient = patientDAO.GetPatient(appointmentObj.idPatient.Value), doctor = doctorDAO.GetDoctor(appointmentObj.idDoctor.Value), rowVersion = appointmentObj.rowVersion }; } } return appointmentBDO; }
public List<AppointmentBDO> GetAllAppointmentsByPatient(int patientId) { List<AppointmentBDO> appointments = null; AppointmentBDO appointmentBDO = null; using (var PHEntities = new PublicHospitalEntities()) { var listInDb = (from appointment in PHEntities.Appointment where appointment.idPatient == patientId select appointment).ToList(); if (listInDb != null) { appointments = new List<AppointmentBDO>(); foreach (Appointment app in listInDb) { appointmentBDO = new AppointmentBDO() { id = app.id, time = Convert.ToDateTime(app.time), serviceType = app.serviceType, patient = new PatientBDO(), doctor = new DoctorBDO(), rowVersion = app.rowVersion }; appointmentBDO.patient.id = (int)app.idPatient; appointmentBDO.doctor.id = (int)app.idDoctor; appointments.Add(appointmentBDO); } return appointments; } else { return null; } } }