private void SaveAppointment(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                var appointment = new Appointment();
                var appointmentDataRepository = new AppointmentDataRepository(EHealthCareDesktopApp.Properties.Settings.Default.UniqueIdentifier);
                appointment.ProviderId = Convert.ToInt32(cmbProvider.SelectedValue.ToString());
                appointment.Notes = txtNotes.Text.Trim();
                appointment.PatientId = EHealthCareDesktopApp.Properties.Settings.Default.PatientID;
                appointment.Type = cmbType.SelectedItem.ToString();
                appointment.Status = "InProgress";
                appointment.StartDate = DateTime.Parse(string.Format("{0} {1}", dtPickerStartDate.SelectedDate.Value.ToShortDateString(), startTime.Text));
                appointment.SpecialtyId = Convert.ToInt32(cmbSpecialty.SelectedValue.ToString());
                appointment.EndDate = DateTime.Parse(string.Format("{0} {1}", dtPickerStartDate.SelectedDate.Value.ToShortDateString(), endTime.Text));
                appointment.Purpose = txtPurpose.Text.Trim();
                appointmentDataRepository.SaveAppointment(appointment);

                if (AppointmentAddedEvent != null)
                    AppointmentAddedEvent("Success");
            }
            catch (Exception ex)
            {
                if (AppointmentAddedEvent != null)
                    AppointmentAddedEvent(string.Format("Problem in adding Appointment: {0}", ex.Message));
            }
        }
 public void UpdateAppointment(int appointmentId, Appointment appointment)
 {
     using (var dataContext = new eHealthCareEntities())
     {
         try
         {
             var appoinmentToUpdate = GetAppointmentById(appointment.PatientId, appointmentId);
             if (appoinmentToUpdate != null)
             {
                 appoinmentToUpdate.ProviderId = appointment.ProviderId;
                 appoinmentToUpdate.Purpose = appointment.Purpose;
                 appoinmentToUpdate.SpecialtyId = appointment.SpecialtyId;
                 appoinmentToUpdate.StartDate = appointment.StartDate;
                 appoinmentToUpdate.Type = appointment.Type;
                 appoinmentToUpdate.EndDate = appointment.EndDate;
                 dataContext.Entry(appoinmentToUpdate).State = EntityState.Modified;
                 dataContext.SaveChanges();
             }
         }
         catch (DbEntityValidationException ex)
         {
             throw new Exception(ex.EntityValidationErrors.GetValidationErrors());
         }
         catch
         {
             throw;
         }
     }
 }
 public void SaveAppointment(Appointment appointment)
 {
     using (var dataContext = new eHealthCareEntities())
     {
         try
         {
             appointment.UniqueIdentifier = uniqueGuid;
             dataContext.Appointments.Add(appointment);
             dataContext.SaveChanges();
         }
         catch (DbEntityValidationException ex)
         {
             throw new Exception(ex.EntityValidationErrors.GetValidationErrors());
         }
         catch
         {
             throw;
         }
     }
 }