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.Navigation;
using System.Windows.Shapes;
using Demo.Classes;

namespace Demo.Pages
{
    /// <summary>
    /// Логика взаимодействия для PageAgentsList.xaml
    /// </summary>
    public partial class PageAgentsList : Page
    {
        List<Agent> AgentClear = ClassDataBase.DB.Agent.ToList();
        List<ProductSale> AgentSales = ClassDataBase.DB.ProductSale.ToList();
        public PageAgentsList()
        {
            InitializeComponent();
            LVAgents.ItemsSource = AgentClear;
        }

        private void TbSalesCount_Loaded(object sender, RoutedEventArgs e)
        {
            TextBlock tb = (TextBlock)sender;
            int id = Convert.ToInt32(tb.Uid);
            List<ProductSale> salesTemp = new List<ProductSale>();
            foreach (ProductSale item in ClassDataBase.DB.ProductSale)
            {
                if (item.AgentID == id)
                {
                    salesTemp.Add(item);
                }
            }
            tb.Text = "Количество продаж: " + salesTemp.Count.ToString();
        }
    }
}
