using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using demo0411.Models;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;

namespace demo0411;

public partial class ListPartner : Window
{
    private List<Partner> partners;
    private int log;
    public ListPartner()
    {
        InitializeComponent();
        partners = Helper.DbContext.Partners.Include(c => c.PartnerType).ToList();
        ListPartners.ItemsSource = partners;
    }

    private void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        new DobavPartner().Show();
        Close();
    }

    private void Border_DoubleTapped(object? sender, Avalonia.Input.TappedEventArgs e)
    {
        int stop = 3;
        new DobavPartner(int.Parse((sender as Border).Tag.ToString()), stop).Show();
        Close();
    }

    private void Button_Click_1(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        log = 1;
        new History(log).Show();
        Close();
    }
    private void Button_Click_2(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        new MainWindow().Show();
        Close();
    }
}