using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ProbnikDemo
{
    /// <summary>
    /// Логика взаимодействия для PgChange.xaml
    /// </summary>
    public partial class PgChange : Window
    {
        Agent agent1 = new Agent();
        public PgChange(Agent agent)
        {
            InitializeComponent();
            agent1 = agent;
            ComboType.ItemsSource = BaseConnect.BaseModel.AgentType.Where(x => x.ID > 0).ToList();
            ComboType.SelectedValuePath = "ID";
            ComboType.DisplayMemberPath = "Title";
            DataContext = agent;
        }

        private void BtnDel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BaseConnect.BaseModel.Agent.Remove(agent1);
                BaseConnect.BaseModel.SaveChanges();
                LoadPages.SwitchPages.Navigate(new PgListAgent());
            }
            catch
            {
                MessageBox.Show("Ошибка");

            }

        }

        private void BtnImg_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
