public static void UpdateDiagnosis(Diagnosis diagnosis)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     context.Diagnoses.AddObject(diagnosis);
     context.ObjectStateManager.ChangeObjectState(diagnosis, EntityState.Modified);
     context.SaveChanges();
 }
        public static IQueryable<Diagnosis> GetDiagnosesByPatientId(int patientId)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            var diagnoses = context.Diagnoses.Include("Doctor").Where(d => d.PatientId == patientId);

            return diagnoses;
        }
Exemplo n.º 3
0
 public static void UpdateDoctor(Doctor doctor)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     context.Doctors.AddObject(doctor);
     context.ObjectStateManager.ChangeObjectState(doctor, EntityState.Modified);
     context.SaveChanges();
 }
Exemplo n.º 4
0
        /// <summary>
        /// Get all users in the database
        /// </summary>
        /// <returns></returns>
        public static IQueryable<User> GetAllUsers()
        {
            MedicalCardEntities context = new MedicalCardEntities();
            var users = context.Users;

            return users.AsQueryable();
        }
 public static Diagnosis GetDiagnosisById(int diagnosisId)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     var diagnosis = context.Diagnoses.Where(p => p.DiagnoseId == diagnosisId).FirstOrDefault();
     context.Detach(diagnosis);
     return diagnosis;
 }
        public static void DeleteConsultationById(int consultationId)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            var consultation = context.Consultations.Where(p => p.ConsultationId == consultationId).FirstOrDefault();

            context.Consultations.DeleteObject(consultation);
            context.SaveChanges();
        }
Exemplo n.º 7
0
        public static void DeletePatientById(int patientId)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            var patient = context.Patients.Where(p => p.PatientId == patientId).FirstOrDefault();

            context.Patients.DeleteObject(patient);
            context.SaveChanges();
        }
 public static IQueryable<Consultation> GetConsultationsByPatientId(int patientId)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     var consultations = context.Consultations
                                 .Include("Doctor")
                                 .Where(p => p.PatientId == patientId);
     return consultations;
 }
        public static void DeleteDiagnosisById(int diagnosisId)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            var diagnosis = context.Diagnoses.Where(p => p.DiagnoseId == diagnosisId).FirstOrDefault();

            context.Diagnoses.DeleteObject(diagnosis);
            context.SaveChanges();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Get user by name from the database
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public static User GetUserByName(string username)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            var user = context.Users.Where(u => u.UserName == username).FirstOrDefault();
            var doctor = user.Doctor;

            return user;
        }
Exemplo n.º 11
0
        public static void DeleteUserById(int userId)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            var user = context.Users.Where(p => p.UserId == userId).FirstOrDefault();

            context.Users.DeleteObject(user);
            context.SaveChanges();
        }
Exemplo n.º 12
0
        public static void DeleteDoctorById(int doctorId)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            var doctor = context.Doctors.Where(p => p.DoctorId == doctorId).FirstOrDefault();

            context.Doctors.DeleteObject(doctor);
            context.SaveChanges();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Get user by name from the database
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public static User GetUserById(int userId)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            var user = context.Users.Include("Doctor")
                                    .Include("Patient")
                                    .Where(u => u.UserId == userId).FirstOrDefault();

            return user;
        }
Exemplo n.º 14
0
 public static Doctor GetDoctorById(int doctorId)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     var doctor = context.Doctors.Where(p => p.DoctorId == doctorId).FirstOrDefault();
     if (doctor != null)
     {
         context.Detach(doctor);
     }
     return doctor;
 }
Exemplo n.º 15
0
 public static void DeleteUser(User user)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (user.EntityState == EntityState.Detached)
     {
         context.Users.Attach(user);
     }
     context.Users.DeleteObject(user);
     context.SaveChanges();
 }
 public static void DeleteConsultation(Consultation consultation)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (consultation.EntityState == EntityState.Detached)
     {
         context.Consultations.Attach(consultation);
     }
     context.Consultations.DeleteObject(consultation);
     context.SaveChanges();
 }
Exemplo n.º 17
0
 public static void DeleteDiagnosis(Diagnosis diagnosis)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (diagnosis.EntityState == EntityState.Detached)
     {
         context.Diagnoses.Attach(diagnosis);
     }
     context.Diagnoses.DeleteObject(diagnosis);
     context.SaveChanges();
 }
Exemplo n.º 18
0
 public static void DeleteDoctor(Doctor doctor)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (doctor.EntityState == EntityState.Detached)
     {
         context.Doctors.Attach(doctor);
     }
     context.Doctors.DeleteObject(doctor);
     context.SaveChanges();
 }
Exemplo n.º 19
0
 public static void DeletePatient(Patient patient)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (patient.EntityState == EntityState.Detached)
     {
         context.Patients.Attach(patient);
     }
     context.Patients.DeleteObject(patient);
     context.SaveChanges();
 }
Exemplo n.º 20
0
 public static Patient GetPatientWithConsultationsAndDiagnosesById(int patientId)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     var patient = context.Patients
                         .Include("Consultations")
                         .Include("Diagnoses")
                         .Where(p => p.PatientId == patientId)
                         .FirstOrDefault();
     context.Detach(patient);
     return patient;
 }
 public static IQueryable<Consultation> GetConsultationsInNextDays(int patientId, int days)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     DateTime fromDate = DateTime.Now;
     DateTime toDate = DateTime.Now.AddDays(3);
     var consultations = context.Consultations
                                 .Include("Patient")
                                 .Where(c => c.PatientId == patientId)
                                 .Where(c => c.ScheduleDate >= fromDate && c.ScheduleDate<= toDate);
     return consultations;
 }
Exemplo n.º 22
0
 public static void InsertDoctor(Doctor doctor)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (doctor.EntityState != EntityState.Detached)
     {
         context.ObjectStateManager.ChangeObjectState(doctor, EntityState.Added);
     }
     else
     {
         context.Doctors.AddObject(doctor);
     }
     context.SaveChanges();
 }
 public static Consultation GetConsultationById(int consultationId)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     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;
 }
Exemplo n.º 24
0
 public static void InsertDiagnosis(Diagnosis diagnosis)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (diagnosis.EntityState != EntityState.Detached)
     {
         context.ObjectStateManager.ChangeObjectState(diagnosis, EntityState.Added);
     }
     else
     {
         context.Diagnoses.AddObject(diagnosis);
     }
     context.SaveChanges();
 }
Exemplo n.º 25
0
        public static void InsertPatient(Patient patient)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            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);
        }
Exemplo n.º 26
0
        public static void UpdatePatient(Patient patient)
        {
            MedicalCardEntities context = new MedicalCardEntities();
            context.Patients.AddObject(patient);
            context.ObjectStateManager.ChangeObjectState(patient, EntityState.Modified);
            context.SaveChanges();

            //detach because object is stateless
            context.Detach(patient);
        }
Exemplo n.º 27
0
 public static IQueryable<Patient> GetPatients()
 {
     MedicalCardEntities context = new MedicalCardEntities();
     return context.Patients;
 }
Exemplo n.º 28
0
 public static void UpdateUser(User user)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     context.Users.AddObject(user);
     context.ObjectStateManager.ChangeObjectState(user, EntityState.Modified);
     context.SaveChanges();
 }
Exemplo n.º 29
0
 public static IQueryable<Diagnosis> GetDiagnoses()
 {
     MedicalCardEntities context = new MedicalCardEntities();
     return context.Diagnoses;
 }
Exemplo n.º 30
0
 public static void InsertUser(User user)
 {
     MedicalCardEntities context = new MedicalCardEntities();
     if (user.EntityState != EntityState.Detached)
     {
         context.ObjectStateManager.ChangeObjectState(user, EntityState.Added);
     }
     else
     {
         context.Users.AddObject(user);
     }
     context.SaveChanges();
 }