public List<AppointmentViewModel> GetViewModel()
 {
     var providerDataRepository = new ProviderDataRepository();
     var apponitmentDataRepository = new AppointmentDataRepository(Guid.Parse(uniqueGuid));
     var appointments = apponitmentDataRepository.GetAllAppointmentData(this.patientId);
     foreach (var appointment in appointments)
     {
         appointmentViewModelList.Add(new AppointmentViewModel
         {
             StartDate = appointment.StartDate,
             EndDate = appointment.EndDate,
             Notes = appointment.Notes,
             ProviderName = providerDataRepository.GetProviderById(appointment.ProviderId),
             Purpose = appointment.Purpose,
             SpecialtyName = apponitmentDataRepository.GetSpecialtiyName(appointment.SpecialtyId),
             Status = appointment.Status,
             Type = appointment.Type
         });
     }
     return appointmentViewModelList;
 }
        private void RegisterProviderButtonClick(object sender, RoutedEventArgs e)
        {
            if (noOfErrorsOnScreen > 0)
            {
                errorLabel.Visibility = System.Windows.Visibility.Visible;
                return;
            }

            bool isMale = false;
            try
            {
                if (rdMale.IsChecked != null && bool.Parse(rdMale.IsChecked.ToString()))
                    isMale = true;
                var providerDataRepository = new ProviderDataRepository();
                providerDataRepository.SaveProviderRecord(new Provider
                {
                    FirstName = txtFirstName.Text.Trim(),
                    LastName = txtLastName.Text.Trim(),
                    MiddleName = txtMiddleName.Text.Trim(),
                    Address = txtAddress.Text.Trim(),
                    Gender = isMale,
                    DOB = dtPicker.SelectedDate.Value,
                    EmailAddress = txtEmailAddress.Text.Trim(),
                    UserName = txtUserName.Text.Trim(),
                    Password = EncryptDecrypt.EncryptData(passWordBox.Password),
                    PhoneNumber = txtPhoneNumber.Text.Trim()
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            this.Hide();
            var mainWindow = new MainWindow();
            mainWindow.ShowDialog();
            this.Close();
        }
        private bool validateUser(string username, string password)
        {
            var providerDataRepository = new ProviderDataRepository();
            password = EncryptDecrypt.EncryptData(password);
            var provider = providerDataRepository.GetProviderByUserNamePassword(username, password);
            if (provider != null)
            {
                if (provider.UserName.Equals(username) && provider.Password.Equals(password))
                {
                    E_HealthCareProviderApp.Properties.Settings.Default.ProviderId = provider.Id;
                    E_HealthCareProviderApp.Properties.Settings.Default.Save();
                    return true;
                }
            }

            return false;
        }
        private void WindowLoaded(object sender, System.Windows.RoutedEventArgs e)
        {
            this.dtPickerEndDate.SelectedDate = DateTime.Now.Date;
            this.dtPickerStartDate.SelectedDate = DateTime.Now.Date;
            this.cmbType.ItemsSource = GetAppointmentTypes();

            try
            {
                var providerDataRepository = new ProviderDataRepository();
                var providers = providerDataRepository.GetAllProviders();
                List<NameValuePairs> nameValuePairs = new List<NameValuePairs>();

                foreach(Provider provider in providers){
                    nameValuePairs.Add(new NameValuePairs(string.Format("{0} {1}", provider.FirstName, provider.LastName), provider.Id.ToString()));
                }

                cmbProvider.ItemsSource = nameValuePairs;
                cmbProvider.DisplayMemberPath = "Name";
                cmbProvider.SelectedValuePath = "Value";

                var appointmentDataRepository = new AppointmentDataRepository(EHealthCareDesktopApp.Properties.Settings.Default.UniqueIdentifier);
                var specialtiesList = appointmentDataRepository.GetAllSpecialties();
                cmbSpecialty.ItemsSource = specialtiesList;
                cmbSpecialty.DisplayMemberPath = "SpecialityName";
                cmbSpecialty.SelectedValuePath = "Id";

                cmbSpecialty.SelectedIndex = 0;
                if (cmbProvider.Items.Count > 0)
                    cmbProvider.SelectedIndex = 0;

                if(cmbType.Items.Count > 0)
                    cmbType.SelectedIndex = 3;
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Problem in loading specialties: '{0}'" , ex.ToString()));
            }
        }