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;
        }
Esempio n. 2
0
 /// <summary>
 /// For filling the suggestions in auto fill for username
 /// </summary>
 /// <param name="key"></param>
 public List <AutoFillViewModel> GetEmpNamesForAutoFill(string key)
 {
     try
     {
         List <AutoFillViewModel> suggetionsList = new List <AutoFillViewModel>();
         if (!string.IsNullOrEmpty(key))
         {
             List <AutoFillDTO> suggestionsDTO = _allUserRepository.GetEmpNamesForAutoFill(key);
             foreach (AutoFillDTO dto in suggestionsDTO)
             {
                 AutoFillViewModel suggestion = new AutoFillViewModel();
                 suggestion.Key   = dto.Key;
                 suggestion.Value = dto.Value;
                 suggetionsList.Add(suggestion);
             }
         }
         return(suggetionsList);
     }
     catch (Exception ex)
     {
         _logger.Log(ex, LogLevel.Error, ex.Message);
         return(null);
     }
 }