public static Diagnosis GetDiagnosisById(int diagnosisId)
        {
            SystemMedContainer context = new SystemMedContainer();
            var diagnosis = context.Diagnoses.Where(p => p.DiagnoseId == diagnosisId).FirstOrDefault();

            context.Detach(diagnosis);
            return(diagnosis);
        }
        public static void UpdateConsultation(Consultation consultation)
        {
            SystemMedContainer context = new SystemMedContainer();

            context.Consultations.AddObject(consultation);
            context.ObjectStateManager.ChangeObjectState(consultation, EntityState.Modified);
            context.SaveChanges();

            //detaching the object - ablity to share between different contexts
            context.Detach(consultation);
        }
Ejemplo n.º 3
0
        public static void UpdatePatient(Patient patient)
        {
            SystemMedContainer context = new SystemMedContainer();

            context.Patients.AddObject(patient);
            context.ObjectStateManager.ChangeObjectState(patient, EntityState.Modified);
            context.SaveChanges();

            //detach because object is stateless
            context.Detach(patient);
        }
        public static Doctor GetDoctorById(int doctorId)
        {
            SystemMedContainer context = new SystemMedContainer();
            var doctor = context.Doctors.Where(p => p.DoctorId == doctorId).FirstOrDefault();

            if (doctor != null)
            {
                context.Detach(doctor);
            }
            return(doctor);
        }
Ejemplo n.º 5
0
        public static Patient GetPatientWithConsultationsAndDiagnosesById(int patientId)
        {
            SystemMedContainer context = new SystemMedContainer();
            var patient = context.Patients
                          .Include("Consultations")
                          .Include("Diagnoses")
                          .Where(p => p.PatientId == patientId)
                          .FirstOrDefault();

            context.Detach(patient);
            return(patient);
        }
        public static Consultation GetConsultationById(int consultationId)
        {
            SystemMedContainer context = new SystemMedContainer();
            var consultation           = context
                                         .Consultations
                                         .Include("Doctor")
                                         .Include("Patient")
                                         .Where(p => p.ConsultationId == consultationId)
                                         .FirstOrDefault();

            //detaching the object - ablity to share between different contexts
            context.Detach(consultation);
            return(consultation);
        }
        public static void InsertConsultation(Consultation consultation)
        {
            SystemMedContainer context = new SystemMedContainer();

            if (consultation.EntityState != EntityState.Detached)
            {
                context.ObjectStateManager.ChangeObjectState(consultation, EntityState.Added);
            }
            else
            {
                context.Consultations.AddObject(consultation);
            }
            context.SaveChanges();
            //detaching the object - ablity to share between different contexts
            context.Detach(consultation);
        }
Ejemplo n.º 8
0
        public static void InsertPatient(Patient patient)
        {
            SystemMedContainer context = new SystemMedContainer();

            if (patient.EntityState != EntityState.Detached)
            {
                context.ObjectStateManager.ChangeObjectState(patient, EntityState.Added);
            }
            else
            {
                context.Patients.AddObject(patient);
            }
            context.SaveChanges();

            //detach because object is stateless
            context.Detach(patient);
        }