public ViewModelEditDoctor(NavigationController controller) : base(controller)
        {
            WidthOfBtn = 300;

            VisibilityOfGoBAck        = Visibility.Collapsed;
            CurrentSpecPanelViewModel = new SpecPanelViewModel(this);
            OpenAddSpecCommand        = new DelegateCommand(() =>
            {
                CurrentSpecPanelViewModel.ClearPanel();
                CurrentSpecPanelViewModel.PanelOpened = true;
            });

            SaveSpecCommand = new DelegateCommand(() =>
            {
                var newType = CurrentSpecPanelViewModel.GetPanelType();
                if (!string.IsNullOrWhiteSpace(newType.Str))
                {
                    CurrentSpecPanelViewModel.PanelOpened = false;

                    Handled = false;

                    Data.SpecializationType.Add((newType));

                    Data.Complete();

                    var DataSourceListbuf = Specializations;
                    Specializations       = new ObservableCollection <SpecDataSoursForEdit>();

                    foreach (var spec in Data.SpecializationType.GetAll)
                    {
                        Specializations.Add(new SpecDataSoursForEdit(spec.Str, spec.id_специлизации));
                    }

                    foreach (var spec in DataSourceListbuf)
                    {
                        if (spec.IsChecked.Value)
                        {
                            Specializations.Where(s => s.id == spec.id).ToList()[0].IsChecked = true;
                        }
                    }

                    Controller.NavigateTo <ViewModelEditDoctor>();
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены");
                }
            });
            RevertSpecCommand = new DelegateCommand(() =>
            {
                CurrentSpecPanelViewModel.PanelOpened = false;
                Handled = false;
            });


            CurrentScintificsPanelViewModel = new ScintificsPanelViewModel(this);
            OpenAddScintificsCommand        = new DelegateCommand(() =>
            {
                CurrentScintificsPanelViewModel.ClearPanel();
                CurrentScintificsPanelViewModel.PanelOpened = true;
            });

            SaveScintificsCommand = new DelegateCommand(() =>
            {
                var newType = CurrentScintificsPanelViewModel.GetPanelType();
                if (!string.IsNullOrWhiteSpace(newType.Str))
                {
                    CurrentScintificsPanelViewModel.PanelOpened = false;

                    Handled = false;

                    Data.ScientificTitleType.Add((newType));

                    Data.Complete();

                    var DataSourceListbuf = Scintifics;
                    Scintifics            = new ObservableCollection <SpecDataSoursForEdit>();

                    foreach (var Scintific in Data.ScientificTitleType.GetAll)
                    {
                        Scintifics.Add(new SpecDataSoursForEdit(Scintific.Str, Scintific.Id));
                    }

                    foreach (var Scintific in DataSourceListbuf)
                    {
                        if (Scintific.IsChecked.Value)
                        {
                            Scintifics.Where(s => s.id == Scintific.id).ToList()[0].IsChecked = true;
                        }
                    }

                    Controller.NavigateTo <ViewModelEditDoctor>();
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены");
                }
            });
            RevertScintificsCommand = new DelegateCommand(() =>
            {
                CurrentScintificsPanelViewModel.PanelOpened = false;
                Handled = false;
            });



            ClickOnAutoComplete = new DelegateCommand <object>(
                (sender) =>
            {
                var buf = (AutoCompleteBox)sender;

                buf.IsDropDownOpen = true;

                buf.FilterMode = AutoCompleteFilterMode.None;
            }
                );
            MessageBus.Default.Subscribe("UpdateNameOfButtonForEditDoctor", UpdateNameOfButton);
            MessageBus.Default.Subscribe("GetDoctorForEditDoctor", GetCurrentDoctor);
            //Date = DateTime.Now;
            base.HasNavigation = true;

            TextHeader = "Редактирование врача";

            nameOfButton = "К списку врачей";

            SetAllFieldsDefault();
            ToDashboardCommand = new DelegateCommand(
                () =>
            {
                MessageBus.Default.Call("GetDoctorForEditDoctor", this, currentDoctor.Id);
            }
                );

            SaveAndGoDoctorListCommand = new DelegateCommand(
                () =>
            {
                if (TestRequiredFields())
                {
                    Doctor bufDoc     = Data.Doctor.Get(currentDoctor.Id);
                    bufDoc.Name       = Name;
                    bufDoc.Sirname    = Surname;
                    bufDoc.Patronimic = Patronimic;
                    bufDoc.Aditional  = Aditional;

                    bool test = true;
                    foreach (var Category in Data.СategoryType.GetAll)
                    {
                        if (Category.Str == СategoryTypeSelectedText)
                        {
                            test             = false;
                            bufDoc.категория = Category.Id;
                            break;
                        }
                    }
                    if (test)
                    {
                        СategoryType newСategory = new СategoryType();
                        newСategory.Str          = СategoryTypeSelectedText;
                        Data.СategoryType.Add(newСategory);
                        Data.Complete();
                        bufDoc.категория = newСategory.Id;
                        Data.Complete();
                    }
                    // bufDoc.категория = CategorySelectedId;
                    Data.Complete();

                    bool specTestbuf = false;
                    foreach (var specOld in SpecializationsOld)
                    {
                        if (specOld.IsChecked == true)
                        {
                            specTestbuf = false;
                            foreach (var spec in Specializations)
                            {
                                if (specOld.Name == spec.Name && spec.IsChecked == true)
                                {
                                    specTestbuf = true;
                                    break;
                                }
                            }
                            if (specTestbuf == false)
                            {
                                foreach (var doctorSpec in Data.DoctorsSpecializations.GetAll)
                                {
                                    if (doctorSpec.id_doctor == currentDoctor.Id && doctorSpec.id_specialization == specOld.id)
                                    {
                                        Data.DoctorsSpecializations.Remove(doctorSpec);
                                        Data.Complete();

                                        specOld.IsChecked = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    //     Data.Complete();
                    foreach (var spec in Specializations)
                    {
                        if (spec.IsChecked == true)
                        {
                            specTestbuf = false;
                            foreach (var specOld in SpecializationsOld)
                            {
                                if (specOld.Name == spec.Name && specOld.IsChecked == true)
                                {
                                    specTestbuf = true;
                                    break;
                                }
                            }
                            if (specTestbuf == false)
                            {
                                DoctorsSpecializations bufDS = new DoctorsSpecializations();
                                bufDS.id_doctor         = currentDoctor.Id;
                                bufDS.id_specialization = spec.id;
                                Data.DoctorsSpecializations.Add(bufDS);
                                Data.Complete();
                            }
                        }
                    }



                    //
                    foreach (var specOld in ScintificsOld)
                    {
                        if (specOld.IsChecked == true)
                        {
                            specTestbuf = false;
                            foreach (var spec in Scintifics)
                            {
                                if (specOld.Name == spec.Name && spec.IsChecked == true)
                                {
                                    specTestbuf = true;
                                    break;
                                }
                            }
                            if (specTestbuf == false)
                            {
                                foreach (var doctorSpec in Data.ScientificTitles.GetAll)
                                {
                                    if (doctorSpec.id_doctor == currentDoctor.Id && doctorSpec.id_title == specOld.id)
                                    {
                                        Data.ScientificTitles.Remove(doctorSpec);
                                        Data.Complete();

                                        specOld.IsChecked = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    Data.Complete();
                    foreach (var spec in Scintifics)
                    {
                        if (spec.IsChecked == true)
                        {
                            specTestbuf = false;
                            foreach (var specOld in ScintificsOld)
                            {
                                if (specOld.Name == spec.Name && specOld.IsChecked == true)
                                {
                                    specTestbuf = true;
                                    break;
                                }
                            }
                            if (specTestbuf == false)
                            {
                                ScientificTitles bufDS = new ScientificTitles();
                                bufDS.id_doctor        = currentDoctor.Id;
                                bufDS.id_title         = spec.id;
                                Data.ScientificTitles.Add(bufDS);
                                Data.Complete();
                            }
                        }
                    }

                    //    Data.Complete();

                    MessageBus.Default.Call("OpenDoctors", this, "");
                    Controller.NavigateTo <ViewModelViewDoctors>();
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены");
                }
            }
                );
            GoToDoctorListCommand = new DelegateCommand(
                () =>
            {
                MessageBus.Default.Call("OpenDoctors", this, "");
                Controller.NavigateTo <ViewModelViewDoctors>();
            }
                );
        }
        public ViewModelAddDoctor(NavigationController controller) : base(controller)
        {
            WidthOfBtn         = 200;
            VisibilityOfGoBAck = Visibility.Visible;

            CurrentSpecPanelViewModel = new SpecPanelViewModel(this);
            OpenAddSpecCommand        = new DelegateCommand(() =>
            {
                CurrentSpecPanelViewModel.ClearPanel();
                CurrentSpecPanelViewModel.PanelOpened = true;
            });

            SaveSpecCommand = new DelegateCommand(() =>
            {
                var newType = CurrentSpecPanelViewModel.GetPanelType();
                if (!string.IsNullOrWhiteSpace(newType.Str))
                {
                    CurrentSpecPanelViewModel.PanelOpened = false;

                    Handled = false;

                    Data.SpecializationType.Add((newType));

                    Data.Complete();

                    var DataSourceListbuf = Specializations;
                    Specializations       = new ObservableCollection <SpecDataSours>();

                    foreach (var spec in Data.SpecializationType.GetAll)
                    {
                        Specializations.Add(new SpecDataSours(spec.Str, spec.id_специлизации));
                    }

                    foreach (var spec in DataSourceListbuf)
                    {
                        if (spec.IsChecked.Value)
                        {
                            Specializations.Where(s => s.id == spec.id).ToList()[0].IsChecked = true;
                        }
                    }

                    Controller.NavigateTo <ViewModelAddDoctor>();
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены");
                }
            });
            RevertSpecCommand = new DelegateCommand(() =>
            {
                CurrentSpecPanelViewModel.PanelOpened = false;
                Handled = false;
            });


            CurrentScintificsPanelViewModel = new ScintificsPanelViewModel(this);
            OpenAddScintificsCommand        = new DelegateCommand(() =>
            {
                CurrentScintificsPanelViewModel.ClearPanel();
                CurrentScintificsPanelViewModel.PanelOpened = true;
            });

            SaveScintificsCommand = new DelegateCommand(() =>
            {
                var newType = CurrentScintificsPanelViewModel.GetPanelType();
                if (!string.IsNullOrWhiteSpace(newType.Str))
                {
                    CurrentScintificsPanelViewModel.PanelOpened = false;

                    Handled = false;

                    Data.ScientificTitleType.Add((newType));

                    Data.Complete();

                    var DataSourceListbuf = Scintifics;
                    Scintifics            = new ObservableCollection <SpecDataSours>();

                    foreach (var Scintific in Data.ScientificTitleType.GetAll)
                    {
                        Scintifics.Add(new SpecDataSours(Scintific.Str, Scintific.Id));
                    }

                    foreach (var Scintific in DataSourceListbuf)
                    {
                        if (Scintific.IsChecked.Value)
                        {
                            Scintifics.Where(s => s.id == Scintific.id).ToList()[0].IsChecked = true;
                        }
                    }

                    Controller.NavigateTo <ViewModelAddDoctor>();
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены");
                }
            });
            RevertScintificsCommand = new DelegateCommand(() =>
            {
                CurrentScintificsPanelViewModel.PanelOpened = false;
                Handled = false;
            });



            ClickOnAutoComplete = new DelegateCommand <object>(
                (sender) =>
            {
                var buf            = (AutoCompleteBox)sender;
                buf.IsDropDownOpen = true;
            }
                );


            MessageBus.Default.Subscribe("RefreshDataForDoctorsForEditUser", RefreshDataForDoctorsForEditUser);
            MessageBus.Default.Subscribe("RefreshDataForNewDoctorsForAddUser", RefreshDataForDoctorsForAddUser);
            MessageBus.Default.Subscribe("RefreshDataForNewDoctors", RefreshDataForDoctors);
            //Date = DateTime.Now;
            base.HasNavigation = true;

            TextHeader = "Добавление врача";

            nameOfButton = "Добавить";

            SetAllFieldsDefault();
            ToDashboardCommand = new DelegateCommand(
                () =>
            {
                Name       = "";
                Surname    = "";
                Patronimic = "";
                Aditional  = "";
                MessageBus.Default.Call("RefreshDataForNewDoctors", this, "");
            }
                );
            GoToDoctorListCommand = new DelegateCommand(
                () =>
            {
                MessageBus.Default.Call("OpenDoctors", this, "");
                Controller.NavigateTo <ViewModelViewDoctors>();
            }
                );
            SaveAndGoDoctorListCommand = new DelegateCommand(
                () =>
            {
                if (TestRequiredFields())
                {
                    currentDoctor = new Doctor();
                    bool test     = true;
                    foreach (var Category in Data.СategoryType.GetAll)
                    {
                        if (Category.Str == СategoryTypeSelectedText)
                        {
                            test = false;
                            currentDoctor.категория = Category.Id;
                            break;
                        }
                    }
                    if (test)
                    {
                        СategoryType newСategory = new СategoryType();
                        newСategory.Str          = СategoryTypeSelectedText;
                        Data.СategoryType.Add(newСategory);
                        Data.Complete();
                        currentDoctor.категория = newСategory.Id;
                    }

                    currentDoctor.Name       = Name;
                    currentDoctor.Sirname    = Surname;
                    currentDoctor.Patronimic = Patronimic;
                    currentDoctor.Aditional  = Aditional;
                    currentDoctor.isEnabled  = true;

                    Data.Doctor.Add(currentDoctor);
                    Data.Complete();
                    foreach (var spec in Specializations)
                    {
                        if (spec.IsChecked == true)
                        {
                            DoctorsSpecializations DoctorSpec = new DoctorsSpecializations();
                            DoctorSpec.id_doctor         = currentDoctor.Id;
                            DoctorSpec.id_specialization = spec.id;
                            Data.DoctorsSpecializations.Add(DoctorSpec);
                            Data.Complete();
                        }
                    }
                    Data.Complete();
                    foreach (var Tytle in Scintifics)
                    {
                        if (Tytle.IsChecked == true)
                        {
                            ScientificTitles DoctorTitle = new ScientificTitles();
                            DoctorTitle.id_doctor        = currentDoctor.Id;
                            DoctorTitle.id_title         = Tytle.id;
                            Data.ScientificTitles.Add(DoctorTitle);
                        }
                    }
                    Data.Complete();
                    MessageBus.Default.Call("OpenDoctors", this, "");
                    Controller.NavigateTo <ViewModelViewDoctors>();
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены");
                }
            }
                );
        }