Beispiel #1
0
        /// <summary>
        /// Диалоговое окно для добавления департамента
        /// </summary>
        public static Department Show()
        {
            WindowAddDepartament   addDepartment           = new WindowAddDepartament();
            AddDepartmentViewModel addDepartamentViewModel = new AddDepartmentViewModel();

            addDepartamentViewModel.Title   = "Добавить депортамент";
            addDepartamentViewModel.AddText = "Добавить";
            addDepartment.DataContext       = addDepartamentViewModel;

            addDepartment.ShowDialog();

            return(addDepartamentViewModel.Department);
        }
        /// <summary>
        /// Диалоговое окно для редактирования департамента
        /// </summary>
        public static Department Show(Department department)
        {
            if (department != null)
            {
                WindowAddDepartament   addDepartment           = new WindowAddDepartament();
                AddDepartmentViewModel addDepartamentViewModel = new AddDepartmentViewModel();

                addDepartamentViewModel.Title           = "Редактировать депортамент";
                addDepartamentViewModel.AddText         = "Изменить";
                addDepartamentViewModel.NameDepartament = department.NameDepartment;
                addDepartment.DataContext = addDepartamentViewModel;

                addDepartment.ShowDialog();

                if (addDepartamentViewModel.Department != null)
                {
                    department.NameDepartment = addDepartamentViewModel.Department.NameDepartment;
                }
            }

            return(department);
        }