using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Security.Cryptography;
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 Penis
{
    /// <summary>
    /// Логика взаимодействия для Page1.xaml
    /// </summary>
    public partial class Page1 : Page
    {
        public Page1()
        {
            InitializeComponent();

        } 
       public void Go(object sender, RoutedEventArgs e)
        {
            MainFrame.Name1.Navigate(new Reg());
        }
        public void GoVhod(object sender, RoutedEventArgs e)
        {
            string CurPass = Pass.Password;
            using (SHA256 hash = SHA256.Create())
            {
                CurPass =
                    BitConverter.ToString(hash.ComputeHash(Encoding.UTF8.GetBytes(CurPass))).Replace("-", "");
                {
                    using (Entities DB = new Entities())
                    {
                        Client client = DB.Client.FirstOrDefault(x => x.Login == Login.Text && x.Password == CurPass);
                        if (client != null)
                        {
                            switch (client.id_Role)
                            {
                                case 1:
                                    MainFrame.Name1.Navigate(new PageAdmin());
                                    break;
                                case 2:
                                    MainFrame.Name1.Navigate(new Page2());
                                    break;
                                default:
                                    MessageBox.Show("Вы не зарегистрированы");
                                    break;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Вы не зарегистрированы");
                        }
                    }
                }
            }
        }

    }
}
