using System.Linq;
using System.Windows;

namespace Hotel_Course_Project
{
    /// <summary>
    /// Логика взаимодействия для RoleAddWindow.xaml
    /// </summary>
    public partial class RoleAddWindow : Window
    {
        public RoleAddWindow()
        {
            InitializeComponent();
        }

        private void CancelBtn_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            StaffRole role = new StaffRole()
            {
                Name = RName.Text
            };
            DataBase.db.StaffRole.Add(role);
            var lastId = DataBase.db.StaffRole.OrderByDescending(item => item.Id).FirstOrDefault().Id;
            DataBase.db.SaveChanges();
            DialogResult = true;
        }
    }
}
