Exemplo n.º 1
0
        private void AddFromListButton_Click(object sender, RoutedEventArgs e)
        {
            var vm    = this.DataContext as SendGroupViewModel;
            var psw   = new PersonsView(1);
            var pswVm = psw.DataContext as PersonsViewModel;

            pswVm.ReadyOnly = true;
            pswVm.Gorod     = vm.City;
            pswVm.VihodDat  = vm.OtprDat;

            pswVm.FindCommand.Execute(null);//psw.FindButton_Click(null,null);
            if (psw.ShowDialog() == true)
            {
                var db = new ProvodnikContext();
                foreach (var id in psw.vm.PersonList.Where(pp => pp.IsSelected).Select(pp => pp.Id))
                {
                    if (vm.Persons.FirstOrDefault(pp => pp.PersonId == id) != null)
                    {
                        continue;
                    }

                    var np = MainWindow.Mapper.Value.Map <SendGroupPersonViewModel>(db.Persons.First(pp => pp.Id == id));

                    np.SendGroupViewModel = vm;
                    if (vm.Persons.Count == 0)
                    {
                        np.IsMain = true;
                    }
                    vm.Persons.Add(np);
                }
            }
        }
Exemplo n.º 2
0
        private void AddFromListButton_Click(object sender, RoutedEventArgs e)
        {
            var vm    = this.DataContext as MedKomZayavkaViewModel;
            var psw   = new PersonsView(1);
            var pswVm = psw.DataContext as PersonsViewModel;

            pswVm.FindCommand.Execute(null);//psw.FindButton_Click(null,null);
            if (psw.ShowDialog() == true)
            {
                var db = new ProvodnikContext();
                foreach (var id in psw.vm.PersonList.Where(pp => pp.IsSelected).Select(pp => pp.Id))
                {
                    if (vm.Persons.FirstOrDefault(pp => pp.PersonId == id) != null)
                    {
                        continue;
                    }

                    var np = MainWindow.Mapper.Value.Map <MedKomZayavkaPersonViewModel>(db.Persons.First(pp => pp.Id == id));

                    np.MedKomZayavkaViewModel = vm;
                    vm.Persons.Add(np);
                }
            }
        }