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 InteractiveKiosk
{
    /// <summary>
    /// Interaction logic for Managers.xaml
    /// </summary>
    public partial class Managers : Window
    {
        InteractiveKioskEntities db = new InteractiveKioskEntities();
        public Managers()
        {
            InitializeComponent();
            Profiles.ItemsSource = db.ParkManagers.ToList();
        }

        private void CancelButton(object sender, RoutedEventArgs e)
        {

        }

        private void Add(object sender, RoutedEventArgs e)
        {

        }

        private void Save(object sender, RoutedEventArgs e)
        {
            db.SaveChanges();
        }

        private void Delete(object sender, RoutedEventArgs e)
        {
            var result = MessageBox.Show("Вы точно хотите уволить сотрудника?", "Подтверждение", MessageBoxButton.YesNo, MessageBoxImage.Question);

           if (result == MessageBoxResult.Yes)
           {
              ParkManager m = (ParkManager)Profiles.SelectedItem;
              db.ParkManagers.Remove(m);
              db.SaveChanges();
              MessageBox.Show("Сотрудник успешно уволен!");
              Profiles.ItemsSource = db.ParkManagers.ToList();

           }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            db = new InteractiveKioskEntities();
        }

        private void Managers_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                this.DragMove();
            }
        }

        private void MinButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void ExitButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            this.Close();
        }

    }
}
