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;
namespace kursach_2._0
{
///
/// Логика взаимодействия для MainWindow.xaml
///
public partial class MainWindow : Window
{
private dealerContext _context;
public MainWindow()
{
InitializeComponent();
_context = new dealerContext();
}
private void AuthClick(object sender, RoutedEventArgs e)
{
if(string.IsNullOrWhiteSpace(log.Text) || string.IsNullOrWhiteSpace(pas.Password))
{
MessageBox.Show("Поля должны быть заполнены");
return;
}
List users;
try
{
users = _context.employees.Where(u => u.login == log.Text && u.password == pas.Password).ToList();
}
catch
{
MessageBox.Show("Произошла ошибка");
return;
}
if (users.Count == 1)
{
// если все ок
Windows.Menu menu = new Windows.Menu();
menu.Show();
Close();
}
else
{
MessageBox.Show("Неверный логин или пароль");
return;
}
}
}
}