using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using WpfApp1.Methods;
using WpfApp1.Windows;
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 WpfApp1.Windows
{
    /// <summary>
    /// Логика взаимодействия для AuthorizationWindow.xaml
    /// </summary>
    public partial class AuthorizationWindow : Window
    {
        CafeEntities db;
        public AuthorizationWindow()
        {
            InitializeComponent();
            db = new CafeEntities();
        }

        private void AuthorizationClick(object sender, RoutedEventArgs e)
        {
            AuthorizationMethod authorizationMethod = new AuthorizationMethod();
            if(authorizationMethod.AuthorizationEnter(LoginText.Text, PasswordText.Password) == true)
            {
                var role = db.Test_User.FirstOrDefault(r => r.Login == LoginText.Text && r.Password == PasswordText.Password);
                switch (role.idPost)
                {
                    case 1:
                        Hide();
                        new AdminWindow().ShowDialog();
                        Application.Current.Shutdown();
                        break;
                    case 2:
                        Hide();
                        new WaiterWindow().ShowDialog();
                        Application.Current.Shutdown();
                        break;
                    case 3:
                        Hide();
                        new CookWindow().ShowDialog();
                        Application.Current.Shutdown();
                        break;
                }
            }
        }
    }
}
