public static DeclarationViewModel GetDeclarationViewModelById(IRepository repository, int id)
        {
            Declaration d = repository.Declaration.Items.First(j => j.Id == id);
            // TypeOfResolution type_of_res = d.Resolution == null ? repository.TypeOfResolution.GetNotDeletedItems().First() : d.Resolution.TypeOfResolution;
            DeclarationViewModel result = new DeclarationViewModel(new DeclarationExportFromDatabase()
            {
                resolution = d.Resolution,
                //   type_of_resolution = d.Resolution.TypeOfResolution,
                reason_for_renews = d.ReasonForRenews.ToList(),
                // добавил соединения с Resolution
                refuse_basis = d.Resolution.RefuseBasises.ToList(),
                license_form = d.LicenseForm,
                license = d.License,
                TypeCreateDeclaration = "Edit",
                declaration = d,
                legal_form_type = d.LegalFormType,
                licensed_activity_type = d.LicensedActivityType,
                addr = d.ActualAddr,
                postal_addr = d.PostalAddr,
                company_export = d.Company == null ? null : new CompanyExportFromDatabase() { company = d.Company }
            }, repository);
            result.UnitsAdd = UnitInDeclarationViewModel.GetListViewModel(repository.UnitInDeclaration.GetAddItemsForDeclaration(id));
            result.UnitsRemove = UnitInDeclarationViewModel.GetListViewModel(repository.UnitInDeclaration.GetRemoveItemsForDeclaration(id));
            result.UnitsEdit = UnitInDeclarationViewModel.GetListViewModel(repository.UnitInDeclaration.GetEditItemsForDeclaration(id));
            result.Revisions = RevisionViewModel.GetListViewModel(repository.Revision.GetItemsForDeclaration(id));
            result.TagsTable = new ValueTagTableViewModel(d.Id, EntitiesForTag.Declaration, repository);
            result.Documents = DocumentViewModel.GetListViewModel(repository.Document.GetItemsForDeclaration(id));
            result.PaymentOrders = PaymentOrderViewModelForDeclaration.GetListViewModel(repository.PaymentOrder.GetItemsForDeclaration(id));
            result.ActionsWithDeclaration = ActionWithDeclarationViewModelForDeclaration.GetListViewModel(repository.ActionWithDeclaration.GetItemsForDeclaration(id));

            int res_id = d.Resolution == null ? 0 : d.ResolutionId.Value;

            if (result.IsProlongType || result.IsReNewType)
            {
                result.DeclarationsInPack = DeclarationViewModelForPack.GetListViewModel(repository.Declaration.GetNotDeletedItems().Where(j => j.Id != d.Id && j.Status == DeclarationStatus.Consideration && j.CompanyId.HasValue && j.CompanyId.Value == d.CompanyId.Value && (j.Type.HasFlag(DeclarationType.Prolong) || j.Type.HasFlag(DeclarationType.Renew))), res_id);
            }

            result.ResolutionTypes = TypeOfResolutionForResolutionViewModel.GetTypeOfResolutionViewModelList(repository, d.Resolution.TypeOfType, d.Resolution);

            result.ResolutionCommissioners = Utils.GetPeopleListByRole(repository, "ResolutionCommissioner");
            foreach (var item in result.ResolutionCommissioners)
            {
                item.IsChecked = d.Resolution.ResolutionCommissioners.Select(x => x.Id).ToList().Contains(item.Id);
            }

            //result.list_Refuse_Basis = Utils.GetPeopleListByRole(repository, "ShowRefuseBasis");
            //foreach (var item in result.list_Refuse_Basis)
            //{
            //    item.IsChecked = d.Resolution.RefuseBasises.Select(x => x.Id).ToList().Contains(item.Id);
            //}

            return result;
        }