コード例 #1
0
        //public User UpdateUser(User user)
        //{
        //    try
        //    {
        //        using (var context = new ApteanClinicContext())
        //        {
        //            context.Entry(user).State = EntityState.Modified;
        //            context.SaveChanges();
        //            return user;
        //        }
        //    }catch(Exception e)
        //    {
        //        ExceptionHandler.PrintException(e, new StackTrace(true));
        //        throw e;
        //    }
        //}

        public static bool CheckEmail(string email)
        {
            try
            {
                UserDataLayer user = new UserDataLayer();
                return(user.GetUser(email) == null);
            }
            catch (Exception e)
            {
                ExceptionHandler.PrintException(e, new StackTrace(true));
                throw e;
            }
        }
コード例 #2
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;
     }
 }
コード例 #3
0
 public void DeleteNurse(Nurse nurse)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             User nurseBasicDetails = nurse.NurseUser;
             context.Entry(nurse).State = EntityState.Deleted;
             context.Nurses.Remove(nurse);
             context.SaveChanges();
             UserDataLayer userData = new UserDataLayer();
             userData.DeleteUser(nurseBasicDetails);
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #4
0
 public void DeleteDoctor(int id)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             var  doctor                   = context.Doctors.Include(d => d.DoctorUser).Where(d => d.Id == id).FirstOrDefault();
             User doctorBasicDetails       = doctor.DoctorUser;
             List <DoctorTime> doctorTimes = context.DoctorTimes.Include(d => d.Doctor).Where(d => d.Doctor.Id == id).ToList();
             for (int i = 0; i < doctorTimes.Count; i++)
             {
                 context.DoctorTimes.Remove(doctorTimes[i]);
             }
             context.Doctors.Remove(doctor);
             context.SaveChanges();
             UserDataLayer userData = new UserDataLayer();
             userData.DeleteUser(doctorBasicDetails);
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }