示例#1
0
 private void ShowView(object obj)
 {
     if (AdminRights)
     {
         AdminViewModel adminViewModel = new AdminViewModel();
         IView          adminView      = new AdminWindow(adminViewModel);
         adminViewModel.settoClose(adminView);
         adminView.Show();
         viewToClose.Close();
     }
     if (PatientRights)
     {
         PatientViewModel patientViewModel = new PatientViewModel();
         IView            patientView      = new PatientWindow(patientViewModel);
         patientViewModel.settoClose(patientView);
         patientView.Show();
         viewToClose.Close();
     }
 }
        public void ShowView(object parameter)
        {
            if (AdminRights)
            {
                AdminViewModel adminViewModel = new AdminViewModel();
                IView          adminView      = new AdminWindow(adminViewModel);
                adminViewModel.settoClose(adminView);
                adminView.Show();
                toClose.Close();
            }

            else if (DoctorRights)
            {
                DoctorViewModel doctorViewModel = new DoctorViewModel();
                IView           doctorView      = new DoctorWindow(doctorViewModel);
                doctorViewModel.settoClose(doctorView);
                doctorView.Show();
                toClose.Close();
            }

            else if (PatientRights)
            {
                PatientViewModel patientViewModel = new PatientViewModel();
                IView            patientView      = new PatientWindow(patientViewModel);
                patientViewModel.settoClose(patientView);
                patientView.Show();
                toClose.Close();
            }

            else
            {
                IView authenticationWindow        = null;
                AuthenticationViewModel viewModel = new AuthenticationViewModel(new AuthenticationService());
                authenticationWindow = new AuthenticationWindow(viewModel);
                viewModel.settoClose(authenticationWindow);
                authenticationWindow.Show();
                toClose.Close();
            }
        }
        public void Register(object parameter)
        {
            ComboBox comboRole = parameter as ComboBox;
            int      role      = Int32.Parse(((ComboBoxItem)comboRole.SelectedItem).Tag.ToString());
            var      context   = new MedicalDBEntities();
            var      users     = context.Users;
            User     user      = new User();
            User     user1     = new User();

            if (Email != null && Name != null && Surname != null && CNP != null && Password != null && Telephone != null && _validationErrors.Values.Count == 0)
            {
                if (this.CheckUser(Email))
                {
                    user.email       = Email;
                    user.nameUser    = Name;
                    user.surnameUser = Surname;
                    user.password    = Password;
                    user.telephone   = Telephone;
                    user.roleUser    = role;
                    user.CNP         = CNP;
                    users.Add(user);

                    if (user.roleUser == 2 && SelectedSpecialization != null)
                    {
                        var    doctors = context.Doctors;
                        Doctor doctor  = new Doctor();
                        doctor.idSpecialization = SelectedSpecialization.idSpecialization;
                        doctor.idUser           = user.idUser;
                        doctors.Add(doctor);
                    }
                    context.SaveChanges();

                    MessageBox.Show("Contul dumneavoastra a fost inregistrat cu succes");
                    IView authenticationWindow = null;

                    if (AdminRights)
                    {
                        AdminViewModel adminViewModel = new AdminViewModel();
                        IView          adminView      = new AdminWindow(adminViewModel);
                        adminViewModel.settoClose(adminView);
                        adminView.Show();
                        toClose.Close();
                    }

                    else
                    {
                        AuthenticationViewModel viewModel = new AuthenticationViewModel(new AuthenticationService());
                        authenticationWindow = new AuthenticationWindow(viewModel);
                        viewModel.settoClose(authenticationWindow);
                        authenticationWindow.Show();
                        toClose.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Exista deja un cont cu acest email");
                }
            }
            else
            {
                MessageBox.Show("Va rugăm să introduceți toate datele");
            }
        }