public bool ChangeAppointmentForce(AppAppointment appointment) { Appointment app = new Appointment(appointment); bool found = false; using (var dbContext = new Context()) { foreach (Appointment item in dbContext.Appointments) { if (item.AppointmentId == app.AppointmentId) { item.Doctor = app.Doctor; item.DiagnosisId = app.DiagnosisId; item.AppointmentTime = app.AppointmentTime; found = true; break; } } if (found) { dbContext.SaveChanges(); return(true); } else { dbContext.Appointments.Add(app); dbContext.SaveChanges(); return(true); } } }
public bool DeleteAppointmentForce(AppAppointment appointment) { Appointment app = new Appointment(appointment); bool found = false; using (var dbContext = new Context()) { foreach (Appointment item in dbContext.Appointments) { if (item.AppointmentId == app.AppointmentId) { app = item; found = true; } } if (found) { dbContext.Appointments.Remove(app); dbContext.SaveChanges(); return(true); } else { return(false); } } }
public bool ChangeAppointment(AppAppointment appointment) { Appointment app = new Appointment(appointment); bool found = false; using (var dbContext = new Context()) { foreach (Appointment item in dbContext.Appointments) { if (item.AppointmentId == app.AppointmentId && item.TimeStamp == app.TimeStamp) { item.Doctor = app.Doctor; item.AppointmentTime = app.AppointmentTime; item.TimeStamp = DateTime.Now; found = true; break; } } if (found) { dbContext.SaveChanges(); return(true); } else { return(false); } } }
public BindingList <AppAppointment> GetAllAppointments() { BindingList <AppAppointment> retVal = new BindingList <AppAppointment>(); using (var dbContext = new Context()) { foreach (Appointment item in dbContext.Appointments) { AppAppointment temp = new AppAppointment(item); if (temp.DiagnosisId == "-1" || temp.DiagnosisId == "0") { temp.DiagnosisId = "-1"; temp.Diagnosis = "There is no diagnosis."; } else { temp.Diagnosis = dbContext.Diagnosis.ToList().Find(x => x.Id.ToString() == temp.DiagnosisId).Description; } retVal.Add(temp); } } return(new BindingList <AppAppointment>(retVal.ToList().OrderBy(x => x.AppointmentTime).ToList())); }
public AddChangeAppointmentViewModel(AppAppointment appointment) { Hours = new BindingList <string>() { "8:00", "8:30", "9:00", "9:30", "10:00", "10:30", "11:00", "11:30", "12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00", "16:30", "17:00", "17:30", }; Doctors = Channel.Instance.UserProxy.GetDoctors(); Patients = Channel.Instance.UserProxy.GetPatients(); if (appointment == null) { if (CurrentUser.Instance.Type == USER_TYPE.PATIENT) { PatientVisible = "Hidden"; Appointment.Patient = CurrentUser.Instance.Username; } else { PatientVisible = "Visible"; } Appointment = new AppAppointment(); Appointment.AppointmentTime = DateTime.Now; TitleContent = "ADD"; AddChangeAppointmentCommand = new MyICommand(OnAddAppointmentExecute, OnAddAppointmentUnExecute); } else { Hour = appointment.AppointmentTime.TimeOfDay.ToString().Split(':')[0] + ":" + appointment.AppointmentTime.TimeOfDay.ToString().Split(':')[1]; TitleContent = "CHANGE"; Appointment = appointment; oldAppointment = new AppAppointment(appointment); AddChangeAppointmentCommand = new MyICommand(OnChangeAppointmentExecute, OnChangeAppointmentUnExecute); } }
public bool AddAppointment(AppAppointment appointment) { try { appointment.DiagnosisId = (appointment.DiagnosisId == "0") ? "-1" : appointment.DiagnosisId; Appointment app = new Appointment(appointment); int oldId = app.Id; using (var dbContext = new Context()) { foreach (Appointment item in dbContext.Appointments) { if (item.Id == app.Id) { return(false); } } app.TimeStamp = DateTime.Now; dbContext.Appointments.Add(app); dbContext.SaveChanges(); if (app.AppointmentId == 0) { app.AppointmentId = app.Id; dbContext.SaveChanges(); } } return(true); } catch { return(false); } }
public AddChangeDiagnosis(AppAppointment appointment) { InitializeComponent(); DataContext = new AddChangeDiagnosisViewModel(appointment) { Window = this }; }
public void OnChangeAppointmentExecute(object parameter) { if (parameter == null) { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Change Appointment command."); if (string.IsNullOrEmpty(Hour) || string.IsNullOrWhiteSpace(Hour)) { Appointment.AppointmentTime = new DateTime(); } Appointment.Validate(); if (Appointment.IsValid) { Appointment.AppointmentTime = new DateTime(Appointment.AppointmentTime.Year, Appointment.AppointmentTime.Month, Appointment.AppointmentTime.Day, int.Parse(Hour.Split(':')[0]), int.Parse(Hour.Split(':')[1]), 0); if (Channel.Instance.AppointmentProxy.Change(Appointment)) { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Change Appointment command done."); CommandHandler.Instance.AddAndExecute(AddChangeAppointmentCommand, oldAppointment); MainWindowViewModel.Refresh.Execute(null); Window.Close(); } else { if (MessageBox.Show("Would you like to override it?", "Appointment modified or deleted", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (Channel.Instance.AppointmentProxy.ChangeForce(Appointment)) { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Force Change Appointment command done."); CommandHandler.Instance.AddAndExecute(AddChangeAppointmentCommand, oldAppointment); } } else { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.ERROR, "Change Appointment command not done."); } MainWindowViewModel.Refresh.Execute(null); } } else { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.ERROR, "Change Appointment command (Appointment info not valid) not done."); } } else { AppAppointment appointment = Channel.Instance.AppointmentProxy.GetOne(((AppAppointment)parameter).AppointmentId); if (Channel.Instance.AppointmentProxy.ChangeForce((AppAppointment)parameter)) { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Change Appointment command redo done."); CommandHandler.Instance.undoObjects[CommandHandler.Instance.undoObjects.Count - 1] = new AppAppointment(appointment); MainWindowViewModel.Refresh.Execute(null); } } }
public void OnDeleteAppointmentUnExecute(object parameter) { if (Channel.Instance.AppointmentProxy.Add((AppAppointment)parameter)) { AppAppointment appointment = Channel.Instance.AppointmentProxy.GetOne(((AppAppointment)parameter).AppointmentId); LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Delete Appointment command undo done."); CommandHandler.Instance.redoObjects[CommandHandler.Instance.redoObjects.Count - 1] = new AppAppointment(appointment); MainWindowViewModel.Refresh.Execute(null); } }
public bool CloneAppointment(AppAppointment appointment) { Appointment app = new Appointment(appointment); Appointment clonedApp = (Appointment)app.Clone(); using (var context = new Context()) { context.Appointments.Add(clonedApp); context.SaveChanges(); clonedApp.AppointmentId = clonedApp.Id; context.SaveChanges(); } return(true); }
public Appointment(AppAppointment appointment) { this.Id = appointment.Id; this.AppointmentId = appointment.AppointmentId; this.Patient = appointment.Patient; this.Doctor = appointment.Doctor; this.AppointmentTime = appointment.AppointmentTime; try { this.DiagnosisId = int.Parse(appointment.DiagnosisId); } catch { } this.TimeStamp = appointment.TimeStamp; }
public bool Clone(AppAppointment appointment) { try { lock (x) { bool retVal = manager.CloneAppointment(appointment); log.LogMessage(LOG_TYPE.INFO, "Clone appointment executed succesfuly."); return(retVal); } } catch { log.LogMessage(LOG_TYPE.ERROR, "Clone appointment executed unsuccesfuly."); return(false); } }
public void OnAddAppointmentExecute(object parameter) { if (parameter == null) { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Add Appointment command."); if (string.IsNullOrEmpty(Hour) || string.IsNullOrWhiteSpace(Hour)) { Appointment.AppointmentTime = new DateTime(); } Appointment.Validate(); if (Appointment.IsValid) { Appointment.AppointmentTime = new DateTime(Appointment.AppointmentTime.Year, Appointment.AppointmentTime.Month, Appointment.AppointmentTime.Day, int.Parse(Hour.Split(':')[0]), int.Parse(Hour.Split(':')[1]), 0); if (Channel.Instance.AppointmentProxy.Add(Appointment)) { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Add Appointment command done."); AppAppointment appointment = Channel.Instance.AppointmentProxy.GetLast(); CommandHandler.Instance.AddAndExecute(AddChangeAppointmentCommand, appointment); MainWindowViewModel.Refresh.Execute(null); Window.Close(); } else { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.ERROR, "Add Appointment command (Id alredy exists) not done."); } } else { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.ERROR, "Add Appointment command (Appointment info not valid) not done."); } } else { if (Channel.Instance.AppointmentProxy.Add((AppAppointment)parameter)) { LoggerHelper.Instance.LogManagerLogging(LOG_TYPE.INFO, "Add Appointment command redo done."); AppAppointment appointment = Channel.Instance.AppointmentProxy.GetLast(); CommandHandler.Instance.undoObjects[CommandHandler.Instance.undoObjects.Count - 1] = new AppAppointment(appointment); MainWindowViewModel.Refresh.Execute(null); } } }
public AddChangeDiagnosisViewModel(AppAppointment appointment) { Appointment = appointment; if (appointment.DiagnosisId == "-1") { Description = ""; TitleContent = "ADD"; AddChangeDiagnosisCommand = new MyICommand(OnAddDiagnosis); } else { Description = Appointment.Diagnosis; TitleContent = "CHANGE"; AddChangeDiagnosisCommand = new MyICommand(OnChangeDiagnosis); } }
public BindingList <AppAppointment> Search(DateTime dateTime, string condition) { BindingList <AppAppointment> retVal = new BindingList <AppAppointment>(); if (condition == "<") { using (var dbContext = new Context()) { foreach (Appointment item in dbContext.Appointments) { if (item.AppointmentTime <= dateTime) { AppAppointment temp = new AppAppointment(item); if (temp.DiagnosisId == "-1" || temp.DiagnosisId == "0") { temp.DiagnosisId = "-1"; temp.Diagnosis = "There is no diagnosis."; } else { temp.Diagnosis = dbContext.Diagnosis.ToList().Find(x => x.Id.ToString() == temp.DiagnosisId).Description; } retVal.Add(temp); } } } } else if (condition == "=") { using (var dbContext = new Context()) { foreach (Appointment item in dbContext.Appointments) { if (item.AppointmentTime == dateTime) { AppAppointment temp = new AppAppointment(item); if (temp.DiagnosisId == "-1" || temp.DiagnosisId == "0") { temp.DiagnosisId = "-1"; temp.Diagnosis = "There is no diagnosis."; } else { temp.Diagnosis = dbContext.Diagnosis.ToList().Find(x => x.Id.ToString() == temp.DiagnosisId).Description; } retVal.Add(temp); } } } } else if (condition == ">") { using (var dbContext = new Context()) { foreach (Appointment item in dbContext.Appointments) { if (item.AppointmentTime >= dateTime) { AppAppointment temp = new AppAppointment(item); if (temp.DiagnosisId == "-1" || temp.DiagnosisId == "0") { temp.DiagnosisId = "-1"; temp.Diagnosis = "There is no diagnosis."; } else { temp.Diagnosis = dbContext.Diagnosis.ToList().Find(x => x.Id.ToString() == temp.DiagnosisId).Description; } retVal.Add(temp); } } } } return(new BindingList <AppAppointment>(retVal.ToList().OrderBy(x => x.AppointmentTime).ToList())); }