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.Attractions
{
    /// <summary>
    /// Interaction logic for NloEdit.xaml
    /// </summary>
    public partial class NloEdit : Window
    {
        InteractiveKioskEntities db = new InteractiveKioskEntities();
        public NloEdit()
        {
            InitializeComponent();
            string Nlo = "НЛО";
            var SelectedNlo = db.Attractions.SingleOrDefault(a => a.AttractionName == Nlo);
            DescriptionNlo.Text = SelectedNlo.DescriptionOfTheAttraction;
            string Nlo1 = "НЛО";
            var SelectedNlo1 = db.Attractions.SingleOrDefault(a => a.AttractionName == Nlo1);
            Rules.Text = SelectedNlo1.RulesOfAttraction;

        }

        private void Save(object sender, RoutedEventArgs e)
        {
            var uRow = db.Attractions.FirstOrDefault();
            uRow.DescriptionOfTheAttraction = DescriptionNlo.Text;
            uRow.RulesOfAttraction = Rules.Text;
            uRow.AttractionCost = Convert.ToInt32(PriceNlo.Text);
            db.SaveChanges();
        }

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

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

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