private void AddModel()
        {
            GroupCharacter model = new GroupCharacter();
            AddGroupCharacterView view = new AddGroupCharacterView(true, model, repository) { ShowInTaskbar = false };
            view.ShowDialog();

            if (view.DialogResult != true) return;

            model.Id = repository.AddGroupCharacter(model);
            if (model.Id == 0)
            {
                MessageBoxWPF.Show(StringProject.ErrorAddRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            AllModel.Add(new GroupCharacterViewModel(model));
        }
        private void AddModel(CreditViewModel model)
        {
            Credit           modelCredit = new Credit();
            User             modelUser   = new User();
            List <Payment>   listPayment = new List <Payment>();
            CreateCreditView view;

            if (model == null)
            {
                view = new CreateCreditView(true, repository, modelUser, modelCredit)
                {
                    ShowInTaskbar = false
                };
            }
            else
            {
                modelUser = repository.FirstUser(model.IdUser);
                view      = new CreateCreditView(false, repository, modelUser, modelCredit)
                {
                    ShowInTaskbar = false
                };
            }

            view.ShowDialog();

            if (view.DialogResult != true)
            {
                return;
            }

            if (model == null)
            {
                //Сохранение пользователя в БД
                modelUser.Id = repository.AddUser(modelUser);
                if (modelUser.Id == 0)
                {
                    MessageBoxWPF.Show(StringProject.ErrorAddRecort, StringProject.ErrorCaption, MessageBoxButton.OK,
                                       MessageBoxImage.Error);
                    return;
                }
            }

            modelCredit.IdUser  = modelUser.Id;
            modelCredit.UserObj = repository.FirstUser(modelUser.Id);
            //Сохранение кредита в БД
            modelCredit.Id = repository.AddCredit(modelCredit);

            if (modelCredit.Id == 0)
            {
                MessageBoxWPF.Show(StringProject.ErrorAddRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            listPayment = repository.CalculationPayment(modelCredit.SummaFull, modelCredit.SummaMonth,
                                                        modelCredit.Stavka, modelCredit.TermMonth, modelCredit.DataStart).ToList();

            foreach (Payment item in listPayment)
            {
                item.IdCredit = modelCredit.Id;
                //Сохранение графика платежей в БД
                repository.AddPayment(item);
            }

            ConditionCredit modelConditionCredit = new ConditionCredit
            {
                Data        = DateTime.Now,
                IdCredit    = modelCredit.Id,
                IdCondition = 1 // оформлен
            };

            //Сохранение состояния кредита в БД
            repository.AddConditionCredit(modelConditionCredit);

            AllModel.Add(new CreditViewModel(modelCredit, repository));
        }