コード例 #1
0
 public User GetUserById(int id)
 {
     using (var context = new ApteanClinicContext())
     {
         return(context.Users.Where(user => user.Id == id).FirstOrDefault());
     }
 }
コード例 #2
0
 public List <Patient> GetAllPatients(string role, int id)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             if (role == "Doctor")
             {
                 Doctor         doctor     = context.Doctors.Include(d => d.DoctorUser).Where(d => d.DoctorUser.Id == id).FirstOrDefault();
                 List <int>     PatientsId = context.Appointments.Where(s => s.DoctorId == doctor.Id).Select(s => s.PatientId).Distinct().ToList();
                 List <Patient> list       = new List <Patient>();
                 foreach (int Id in PatientsId)
                 {
                     list.Add(context.Patients.Include(p => p.PatientUser).Where(a => a.Id == Id).FirstOrDefault());
                 }
                 return(list);
             }
             else
             {
                 return(context.Patients.Include(p => p.PatientUser).ToList());
             }
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #3
0
        public int?GetAvailableNurse(DateTime date, int time)
        {
            try
            {
                using (var context = new ApteanClinicContext())
                {
                    List <int> TotalNurse = context.Nurses
                                            .Select(n => n.Id).ToList();

                    if (TotalNurse.Count == 0)
                    {
                        return(null);
                    }

                    List <int> BusyNurse = context.Appointments
                                           .Where(d => d.Date == date && d.Time == time)
                                           .Select(n => n.NurseId).ToList();

                    var list           = TotalNurse.Except(BusyNurse);
                    int?AvailableNurse = list.FirstOrDefault();
                    return(AvailableNurse);
                }
            }catch (Exception e)
            {
                ExceptionHandler.PrintException(e, new StackTrace(true));
                throw e;
            }
        }
コード例 #4
0
 public void ChangePassword(string newPassword, int id)
 {
     using (var context = new ApteanClinicContext())
     {
         User user = context.Users.Select(a => a).Where(a => a.Id == id).SingleOrDefault();
         user.Password             = user.ConfirmPassword = newPassword;
         context.Entry(user).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #5
0
 public List <Appointment> GetDoctorAppointments(int doctorId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Appointments.Where(a => a.DoctorId == doctorId).OrderByDescending(a => a.Date).OrderByDescending(a => a.Time).ToList());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #6
0
 public Doctor GetDoctorById(int id)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Doctors.Include(d => d.DoctorUser).Where(d => d.Id == id).FirstOrDefault());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #7
0
 //Returns a list of doctor of particular speciality
 public List <Doctor> GetDoctorsBySpeciality(Speciality speciality)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Doctors.Include(d => d.DoctorUser).Where(d => d.Speciality == speciality).ToList());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #8
0
 public List <Doctor> GetAllDoctors()
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Doctors.Include(d => d.DoctorUser).ToList());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #9
0
 public List <Appointment> GetDoctorUpcomingAppointments(int docId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Appointments.Where(a => a.DoctorId == docId).Where(a => a.Status == AppointmentStatus.Approved).ToList());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #10
0
 public List <int> GetDocotorBookedSlots(int id, DateTime date)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Appointments.Where(a => a.DoctorId == id).Where(a => a.Date == date && (a.Status == AppointmentStatus.Pending || a.Status == AppointmentStatus.Approved)).Select(a => a.Time).ToList());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #11
0
 public List <DoctorTime> GetDoctorTimeSlot(int id)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.DoctorTimes.Where(t => t.Doctor.Id == id).ToList());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #12
0
 public void UpdateAdminInfo(User user)
 {
     using (var context = new ApteanClinicContext())
     {
         User userTemp = context.Users.Where(u => u.Id == user.Id).FirstOrDefault();
         userTemp.Gender               = user.Gender;
         userTemp.Name                 = user.Name;
         userTemp.BloodGroup           = user.BloodGroup;
         userTemp.Email                = user.Email;
         userTemp.Contact              = user.Contact;
         context.Entry(userTemp).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #13
0
 public MedicinesQuantity GetInvoiceByAppointmentId(int appointmentId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Medicine_Quantity.Where(d => d.Appointment_Id == appointmentId).FirstOrDefault());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #14
0
 public List <Nurse> GetAllNurses()
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Nurses.Include(n => n.NurseUser).ToList());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #15
0
 public List <Appointment> GetAppointmentsById(int patientId, int appointmtnId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Appointments.Where(a => a.Id == appointmtnId).Where(a => a.PatientId == patientId).ToList());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #16
0
 public Nurse GetNurseById(int id)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Nurses.Include(n => n.NurseUser).Where(n => n.Id == id).FirstOrDefault());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #17
0
 public Appointment GetAppointmentsById(int appointmtnId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Appointments.Where(a => a.Id == appointmtnId).FirstOrDefault());
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #18
0
 public void Dispose()
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             context.Dispose();
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #19
0
 public void RemovePatient(Patient patient)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             //Remove appointments of patient
             List <Appointment> appointments = context.Appointments.Where(a => a.PatientId == patient.Id).ToList();
             foreach (var appointment in appointments)
             {
                 //Remove medical history of patient
                 List <MedicalHistory> medicalHistories = context.MedicalHistories.Where(a => a.AppointmentId == appointment.Id).ToList();
                 foreach (var medicalHistory in medicalHistories)
                 {
                     context.Entry(medicalHistory).State = EntityState.Deleted;
                     context.MedicalHistories.Remove(medicalHistory);
                 }
                 //Remove Medicines quantity related to patient
                 List <MedicinesQuantity> medicines = context.Medicine_Quantity.Where(a => a.Appointment_Id == appointment.Id).ToList();
                 foreach (var medicine in medicines)
                 {
                     context.Entry(medicine).State = EntityState.Deleted;
                     context.Medicine_Quantity.Remove(medicine);
                 }
                 //Remove invoices of patient
                 List <Invoice> invoices = context.Invoices.Where(a => a.Appointment_Id == appointment.Id).ToList();
                 foreach (var invoice in invoices)
                 {
                     context.Entry(invoice).State = EntityState.Deleted;
                     context.Invoices.Remove(invoice);
                 }
                 context.Entry(appointment).State = EntityState.Deleted;
                 context.Appointments.Remove(appointment);
             }
             //Remove patient
             User patientBasicDetials = patient.PatientUser;
             context.Entry(patient).State = EntityState.Deleted;
             context.Patients.Remove(patient);
             context.SaveChanges();
             UserDataLayer userData = new UserDataLayer();
             userData.DeleteUser(patientBasicDetials);
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #20
0
 public int GetTotalAppointments(DateTime date, int Time, int Doctor)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Appointments.Where(a => a.Date == date).Where(a => a.Time == Time).Where(a => a.DoctorId == Doctor).Count());
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #21
0
 public List <MedicalHistory> GetPatientMedicalHistory(int patientId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.MedicalHistories.Where(m => m.PatientId == patientId).ToList());
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #22
0
 public int GetNumberOfInvoices()
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Invoices.Count());
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #23
0
 public List <Appointment> GetAppointments()
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Appointments.ToList());
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #24
0
 public int GetAppointmentDetailsByInvoiceId(int InvoiceId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Invoices.Where(m => m.Id == InvoiceId).Select(m => m.Appointment_Id).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #25
0
 public int GetMedicineCost(int MedicineId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(Convert.ToInt32(context.Medicines.Include(m => m.Cost).Where(m => m.Id == MedicineId).Select(m => m.Cost).FirstOrDefault()));
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #26
0
 public MedicinesQuantity CheckIdInList(int Appointment_Id)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Medicine_Quantity.Where(m => m.Appointment_Id == Appointment_Id).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #27
0
 public List <MedicinesQuantity> GetPatientMedicines(int AppointmentId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Medicine_Quantity.Where(m => m.Appointment_Id == AppointmentId).ToList());
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #28
0
 public Patient GetPatienById(int id)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Patients.Include(p => p.PatientUser).Where(p => p.Id == id).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #29
0
 public int GetPatientIdByAppointmentId(int Appointment_Id)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Appointments.Where(a => a.Id == Appointment_Id).Select(a => a.PatientId).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #30
0
 public string GetMedicineName(int MedicineId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             return(context.Medicines.Where(a => a.Id == MedicineId).Select(a => a.Name).FirstOrDefault());
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }