コード例 #1
0
        public OrganizationViewModel()
        {
            _riskListRepository = new RiskRepository();
            Validator           = GetValidator();// без инициализации это свойство NULL.
            ICountryRepository countryRepos = new CountryRepository();

            countryRepos.GetCountries();
        }
コード例 #2
0
        public NewOrganizationViewModel()
        {
            _newOrgrepo = new NewOrganizationRepository();

            _countryRepository = new CountryRepository();                            //создаем экземпляр класса CountryRepository, который унаследован от интрефейса ICountryRepository
            List <CountryModel> countries = _countryRepository.GetCountries();       // создаем список объектов с типом CountryModel при помощи метода обязательного (Интрерфес) методом GetCountries из репы
            var countryVM = CountryMapper.CountryModelToCountryViewModel(countries); // при помощи статического метода CountryModelToCountryViewModel из класса CountryMapper приводим тип из Модели во Вью модель, чтобы наша вью модель могла работать с данными

            _sectionRepository = new SectionRepository();
            List <SectionModel> sections = _sectionRepository.GetSections();
            var sectionVM = SectionMappers.SectionModelToSectionViewModel(sections);

            _riskListRepository = new RiskRepository();

            var risks = _riskListRepository.GetRisks();

            //ValueChanged - обработчик событий. В калькуляторе у нас есть событие, которое вызывается при смене значения в калькуляторе(при добавлении и удаоении значений)
            /// мы подписываемся на изменение ValueChanged
            RiskCalculator.ValueChanged += RiskCalculatorValueChanged;

            Person1 = new PersonViewModel(countryVM)
            {
                PrevLiquidated  = new NegativeRiskCheckBoxViewModel(risks.PrevLiquidated),
                PrevBankruptcy  = new NegativeRiskCheckBoxViewModel(risks.PrevBankruptcy),
                PrevExecuteProc = new NegativeRiskCheckBoxViewModel(risks.PrevExecuteProc),
                PrevStateDebt   = new NegativeRiskCheckBoxViewModel(risks.PrevStateDebt),
                PrevTaxDebt     = new NegativeRiskCheckBoxViewModel(risks.PrevTaxDebt),
                NegativDataPers = new NegativeRiskCheckBoxViewModel(risks.NegativData)
            };

            Organization = new OrganizationViewModel(countryVM, sectionVM)
            {
                BrokerClient     = new PositiveRiskCheckBoxViewModel(risks.BrokerClient),
                PrevBrokerClient = new PositiveRiskCheckBoxViewModel(risks.PrevBrokerClient),
                Manufacturer     = new PositiveRiskCheckBoxViewModel(risks.Manufacturer),
                Reputation       = new PositiveRiskCheckBoxViewModel(risks.Reputation),
                OwnershipOrg     = new PositiveRiskCheckBoxViewModel(risks.OwnershipOrg),

                TaxDebt = new NegativeRiskCheckBoxViewModel(risks.TaxDebt),
                DebtsEnforcementDocuments = new NegativeRiskCheckBoxViewModel(risks.DebtsEnforcementDocuments),
                FalseBusiness             = new NegativeRiskCheckBoxViewModel(risks.FalseBusiness),
                SpecialRisc              = new NegativeRiskCheckBoxViewModel(risks.SpecialRisc),
                ExecuteProc              = new NegativeRiskCheckBoxViewModel(risks.ExecuteProc),
                BankruptcyProc           = new NegativeRiskCheckBoxViewModel(risks.BankruptcyProc),
                LiquidationProc          = new NegativeRiskCheckBoxViewModel(risks.LiquidationProc),
                NegativData              = new NegativeRiskCheckBoxViewModel(risks.NegativData),
                ExchengeTradingDisorders = new NegativeRiskCheckBoxViewModel(risks.ExchengeTradingDisorders),
            };

            SaveCommand       = new RelayCommand(Save, CanSave);
            ClearCommand      = new RelayCommand(Clear);
            Risk              = RiskCalculator.Value;
            AutoFill          = new RelayCommand(FillOracleDataOrgPers);
            AutoFillViewModel = new AutoFillViewModel();

            Countries = countryVM;
        }