using Microsoft.AspNetCore.Mvc;
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 KinoPoisk
{
    /// <summary>
    /// Логика взаимодействия для MainMenu.xaml
    /// </summary>
    public partial class MainMenu : Window
    {
        public MainMenu()
        {
            InitializeComponent();
            Listfilms.AutoGenerateColumns = true;

            WelcomeText.Content = $"Привет, {UserData.LastName} {UserData.FirstName}";
            if (UserData.Status == 2)
            {
                Admin.IsEnabled = false;
            }
            KinoPoiskContext context = new KinoPoiskContext();
            var Films = context.Films;
            Listfilms.ItemsSource = Films.ToList();
            

        }

        private void Search_Click(object sender, RoutedEventArgs e)
        {
            KinoPoiskContext context = new KinoPoiskContext();
            var Films = context.Films;

            if (!String.IsNullOrEmpty(SearchBox.Text))
            {
                Listfilms.ItemsSource = (Films.Where(s => s.NameFilm.Contains(SearchBox.Text))).ToList();
            }
        }

        private void Admin_Click(object sender, RoutedEventArgs e)
        {

            AdminPanel amd = new AdminPanel();
            this.Hide();
            amd.Show();

        }

        private void BuyTiket_Click(object sender, RoutedEventArgs e)
        {
            BuyTicketsWin buyTicketsWin = new BuyTicketsWin();
            this.Hide();
            buyTicketsWin.Show();
        }
    }
}
