//public IEnumerable<LotacaoModel> PesquisaLotacao { get { return _pesquisaLotacao; } }


        public IEnumerable <LotacaoModel> ObterLotacaoAtivaPorNome(string nome)
        {
            return(_appServico.ObterLotacaoesAtivaPorNome(nome).Select(domain => {
                var vm = new LotacaoModel();
                vm.DominioToModel(domain);
                return vm;
            }).ToList());
        }
Beispiel #2
0
        private void Form2_Load(object sender, EventArgs e)
        {
            IEnumerable <LotacaoModel> lotacaoViewModels = _appServico.ObterTodos().Select(domain => {
                var vm = new LotacaoModel();
                vm.DominioToModel(domain);
                return(vm);
            }).ToList();



            var lotacaoBindingList = new BindingList <LotacaoModel>(lotacaoViewModels.ToList());

            dataGridView1.SelectionChanged += new EventHandler(dataGridView1_SelectionChanged);
            // lotacaoVMbindingSource.DataSource = lotacaoBindingList;
            dataGridView1.DataSource    = lotacaoBindingList;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;



            //currentLotacaoModel = lotacaoBindingList.FirstOrDefault();
            //this.ViewModel.Model.IdLotacao = currentLotacaoModel.IdLotacao;
            //this.ViewModel.Model.Descricao = currentLotacaoModel.Descricao;
            //this.ViewModel.Model.Sigla = currentLotacaoModel.Sigla;
            //this.ViewModel.Model.Inativa = currentLotacaoModel.Inativa;


            //var lotacaoObservable = new ObservableCollection<LotacaoViewModel>(lotacaoViewModels);
            //lotacaoVMbindingSource.DataSource = lotacaoObservable;
            //dataGridView1.DataSource = lotacaoObservable;

            //button1.DataBindings.Add("Enabled", ckInativo, "Checked");

            // txtId.DataBindings.Add("Text", lotacaoVMbindingSource.Current, "IdLotacao");
            //txtDescricao.DataBindings.Add("Text", lotacaoVMbindingSource., "Descricao", false, DataSourceUpdateMode.OnPropertyChanged);
            //txtSigla.DataBindings.Add("Text", lotacaoVMbindingSource.Current, "Sigla",false, DataSourceUpdateMode.OnPropertyChanged);
            //textBox2.DataBindings.Add("Text", txtSigla, "Text");

            //ckInativo.DataBindings.Add("Checked", lotacaoVMbindingSource.Current, "Inativo");
        }