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 Met_Fam
{
    /// <summary>
    /// Логика взаимодействия для Window3.xaml
    /// </summary>
    public partial class WindowReg : Window
    {
        ViewModel2 viewModel2 = new ViewModel2();
        public User buffer;
        public WindowReg()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            List<User> code = DataBase.BaseModel.User.ToList();
            var lastItem = code.Last();
            User user = new User()
            {
                ID_User = lastItem.ID_User + 1,
                Surname_User = txtSuName.Text,
                Name_User = txtName.Text,
                Login_User = txtLogin.Text,
                Password_User = txtPass.Password,
                Phone_User = txtPhon.Text,
                Address = txtAdres.Text,
                ID_Role = 2,
            };
            DataBase.BaseModel.User.Add(user);
            DataBase.BaseModel.SaveChanges();
            DataBase.BaseModel = new MFSystemEntities();
            new WindowShop().Show();
            this.Close();
        }
    }
}