protected void ButtonDeleteMessage_Click(object sender, EventArgs e) { HospitalSystemEntities1 entities = new HospitalSystemEntities1(); List <Message> messages = getMessages(); Message selected = messages[DropDownListMessages.SelectedIndex]; entities.Messages.Attach(selected); entities.Messages.Remove(selected); entities.SaveChanges(); ListBoxMessages.Items.Clear(); DropDownListMessages.Items.Clear(); if (messages.Count < 1) { ListBoxMessages.Items.Add("You have no messages."); DropDownListMessages.Items.Add("You have no messages."); } else { foreach (Message message in messages) { ListBoxMessages.Items.Add( message.MessageFROM + ": " + message.Message1 ); DropDownListMessages.Items.Add( message.MessageFROM + ": " + message.Message1 ); } } ListBoxMessages.DataBind(); DropDownListMessages.DataBind(); }
private bool sendMessage(Doctor doctor, Patient patient, string content) { HospitalSystemEntities1 entities = new HospitalSystemEntities1(); Message msg = new Message(); msg.MessageFROM = doctor.FirstName + " " + doctor.LastName; msg.MessageTO = patient.FirstName + " " + patient.LastName; msg.Message1 = content; msg.Date = new DateTime(); entities.Messages.Add(msg); entities.SaveChanges(); return(true); }
/** * Deletes the appointment corresponding with the given Appointment * object, if one exists * * @param appointment Appointment object representing the information * of the appointment that is desired to be deleted * @returns true on success, false on failure */ public static bool DeleteAppointment(int appointmentID) { HospitalSystemEntities1 entities = new HospitalSystemEntities1(); List <Appointment> matched = (from appt in entities.Appointments where appt.AppointmentID == appointmentID select appt).ToList(); if (matched.Count < 1) { return(false); } entities.Appointments.Remove(matched.First()); entities.SaveChanges(); return(true); }
/** * Creates an appointment in the database with the information * given in the provided Appointment object * * @param appointment Appointment object representing appointment * information * @returns true on success, false on failure */ public static bool CreateAppointment(AppointmentInfo appointment) { HospitalSystemEntities1 entities = new HospitalSystemEntities1(); Appointment appt = new Appointment(); appt.Date = appointment.TimeSlot; appt.Time = appointment.TimeSlot; appt.PatientID = appointment.PatientID; appt.DoctorID = appointment.DoctorID; appt.Purpose = appointment.Purpose; appt.VisitSummary = ""; entities.Appointments.Add(appt); entities.SaveChanges(); return(true); }