private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Sages.Clear();
            foundSages.Items.Refresh();

            using (SgDbContext sbc = new SgDbContext())
            {
                string sName = sageName.Text;
                string sCity = sageCity.Text;

                ICollection <Sage> sages = new List <Sage>();
                if (sName != "" && sCity != "")
                {
                    sages = sbc.Sages.Where(p => p.Name == sName).Where(p => p.City == sCity).ToList();
                }
                else if (sName != "" && sCity == "")
                {
                    sages = sbc.Sages.Where(p => p.Name == sName).ToList();
                }
                else if (sName == "" && sCity != "")
                {
                    sages = sbc.Sages.Where(p => p.City == sCity).ToList();
                }
                else
                {
                    sages = sbc.Sages.Select(p => p).ToList();
                }
                foreach (var sg in sages)
                {
                    Sages.Add(sg);
                }
            }

            foundSages.Items.Refresh();
        }
Exemple #2
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            string sageName = sageNameField.Text;
            string sageCity = sageCityField.Text;

            Sages.Clear();
            using (SgDbContext sbc = new SgDbContext())
            {
                Sages.Clear();
                if (sageName != "" && sageCity != "")
                {
                    foreach (var sage in sbc.Sages.Where(p => p.Name == sageName).Where(p => p.City == sageCity).ToList())
                    {
                        Sages.Add(sage);
                    }
                }
                else if (sageName != "" && sageCity == "")
                {
                    foreach (var sage in sbc.Sages.Where(p => p.Name == sageName).ToList())
                    {
                        Sages.Add(sage);
                    }
                }
                else if (sageName == "" && sageCity != "")
                {
                    foreach (var sage in sbc.Sages.Where(p => p.City == sageCity).ToList())
                    {
                        Sages.Add(sage);
                    }
                }
                else
                {
                    foreach (var sage in sbc.Sages.Select(p => p).ToList())
                    {
                        Sages.Add(sage);
                    }
                }
                resultGrid.ItemsSource = Sages;
                resultGrid.Items.Refresh();
            }
        }