using System.Linq;
using System.Windows;

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

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

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