using Sessioa.BaseModel;
using Sessioa.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
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;

namespace Sessioa.Pages
{
    /// <summary>
    /// Логика взаимодействия для Autorization.xaml
    /// </summary>
    public partial class Autorization : Page
    {
        int n = 0;
        public Autorization()
        {
            InitializeComponent();
        }

        private void Sign_Click(object sender, RoutedEventArgs e)
        {
            User user = BaseClass.C_Base.User.FirstOrDefault(x => x.UserLogin == Login.Text);
            if(user != null)
            {
                if(user.UserPassword == Password.Text)
                {
                    FrameClass.C_Frame.Navigate(new ProductsPage());
                }
                else
                {
                    MessageBox.Show("Пароль указан неверно", "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Error);
                    n++;
                }
            }
            else
            {
                MessageBox.Show("Пользователя нет в системе", "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Error);
                n++;
            }
            if (n == 2)
            {
                Thread.Sleep(10000);
                n = 0;
            }
        }

        private void Mode_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
