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(); } }
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(); } }
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; } }
public void createInvoice(Invoice invoice) { try { using (var context = new ApteanClinicContext()) { context.Invoices.Add(invoice); context.SaveChanges(); } } catch (Exception e) { ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }
public Nurse AddNurse(Nurse nurse) { try { using (var context = new ApteanClinicContext()) { context.Nurses.Add(nurse); context.SaveChanges(); return(nurse); } }catch (Exception e) { ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }
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; } }
public Appointment FixAppointment(Appointment appointment) { try { using (var context = new ApteanClinicContext()) { context.Appointments.Add(appointment); context.SaveChanges(); return(appointment); } } catch (Exception e) { ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }
public Patient AddPatient(Patient patient) { try { using (var context = new ApteanClinicContext()) { context.Patients.Add(patient); context.SaveChanges(); return(patient); } } catch (Exception e) { ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }
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; } }
public void GetPastAppointments(DateTime date) { try { using (var context = new ApteanClinicContext()) { var appointments = context.Appointments.Where(a => a.Date < date).ToList(); appointments.Where(a => a.Status == AppointmentStatus.Pending || a.Status == AppointmentStatus.Approved).ToList().ForEach(a => a.Status = AppointmentStatus.Cancelled); context.SaveChanges(); } } catch (Exception e) { ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }
public Doctor AddDoctor(Doctor doctor) { try { using (var context = new ApteanClinicContext()) { context.Doctors.Add(doctor); context.DoctorTimes.AddRange(doctor.ShiftTime); context.SaveChanges(); return(doctor); } }catch (Exception e) { ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }
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; } }
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; } }
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; } }
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; } }
public void SaveData(List <MedicinesQuantity> medicine) { try { using (var context = new ApteanClinicContext()) { foreach (var item in medicine) { context.Medicine_Quantity.Add(item); context.SaveChanges(); } } } catch (Exception e) { ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }
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; } }
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; } }
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; } }