コード例 #1
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;
     }
 }
コード例 #2
0
 public void UpdateNurseDetails(Nurse nurse)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             User user = nurse.NurseUser;
             context.Entry(user).State  = EntityState.Modified;
             context.Entry(nurse).State = EntityState.Modified;
             context.SaveChanges();
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #3
0
 public void EditDoctorDetails(Doctor doctor)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             User user = doctor.DoctorUser;
             context.Entry(user).State   = EntityState.Modified;
             context.Entry(doctor).State = EntityState.Modified;
             context.SaveChanges();
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #4
0
 public void UpdatePatientDetails(Patient patient)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             User user = patient.PatientUser;
             context.Entry(user).State    = EntityState.Modified;
             context.Entry(patient).State = EntityState.Modified;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #5
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();
     }
 }
コード例 #6
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();
     }
 }
コード例 #7
0
 public User UpdateUser(User user)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             context.Users.Add(user);
             context.Entry(user).State = EntityState.Modified;
             context.SaveChanges();
             return(user);
         }
     }catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #8
0
 public void DeleteUser(User user)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             context.Entry(user).State = EntityState.Deleted;
             context.Users.Remove(user);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #9
0
 public void UpdateAppointments(List <Appointment> appointments)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             context.Appointments.AddRange(appointments);
             // context.Entry(appointments).State = EntityState.Modified;
             context.Entry <List <Appointment> >(appointments).State = EntityState.Modified;
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #10
0
 public Appointment UpdateAppointment(Appointment appointment)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             context.Appointments.Add(appointment);
             context.Entry(appointment).State = EntityState.Modified;
             context.SaveChanges();
             return(appointment);
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
コード例 #11
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;
     }
 }
コード例 #12
0
 public void DeleteInvoice(int InvoiceId)
 {
     try
     {
         using (var context = new ApteanClinicContext())
         {
             int AppointmentId = GetAppointmentDetailsByInvoiceId(InvoiceId);
             var Medicines     = context.Medicine_Quantity.Where(a => a.Appointment_Id == AppointmentId).ToList();
             context.Medicine_Quantity.RemoveRange(Medicines);
             Invoice invoice = context.Invoices.Find(InvoiceId);
             context.Entry(invoice).State = EntityState.Deleted;
             context.Invoices.Remove(invoice);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }