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.Events
{
    /// <summary>
    /// Interaction logic for ChildrensDayEdit.xaml
    /// </summary>
    public partial class ChildrensDayEdit : Window
    {
        InteractiveKioskEntities db = new InteractiveKioskEntities();
        public ChildrensDayEdit()
        {
            InitializeComponent();

            string Children = "День защиты детей";
            var SelectedChildren = db.Events.SingleOrDefault(a => a.EventName == Children);
            DescriptionChildren.Text = SelectedChildren.EventDescription;
            //Beginning.Text = SelectedChildren.BeginningOfEvent;
            //Ending.Text = SelectedChildren.EndingOfEvent;
        }

        private void BackButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            EventsWindow ew = new EventsWindow();
            ew.Show();
            this.Close();
        }

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

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

        private void Save(object sender, RoutedEventArgs e)
        {
            var uRow = db.Events.FirstOrDefault();
            uRow.EventDescription = DescriptionChildren.Text;
            uRow.BeginningOfEvent = Convert.ToDateTime(Beginning.Text);
            uRow.EndingOfEvent = Convert.ToDateTime(Ending.Text);
            db.SaveChanges();
        }
    }
}
