using System;
using System.Windows;

namespace Hotel_Course_Project
{
    /// <summary>
    /// Логика взаимодействия для MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        Staff _user;
        public MainWindow(Staff user)
        {
            InitializeComponent();
            PChanger.MainFrame = MainFrame;
            _user = user;
            switch (user.Id_StaffRole)
            {
                case 1:
                    MainFrame.Navigate(new AdminPage(user));
                    break;
                case 2:
                    MainFrame.Navigate(new HostelsPage(user));
                    break;
            }
            if (user.Id_HelpQuestion == null)
            {
                HelpQustionWindow helpQustion = new HelpQustionWindow(user);
                helpQustion.ShowDialog();
                DataBase.db.SaveChanges();
            }
        }
        private void MainFrame_ContentRendered(object sender, EventArgs e)
        {
            var visibleExitBtn = PChanger.MainFrame.CanGoBack ? ExitBtn.Visibility = Visibility.Collapsed : ExitBtn.Visibility = Visibility.Visible;
            if (Title == "Добавление заказа")
            {
                var visibleBackBtnOnOrder = BackBtn.Visibility == Visibility.Collapsed;
            }
            else
            {
                var visibleBackBtn = PChanger.MainFrame.CanGoBack ? BackBtn.Visibility = Visibility.Visible : BackBtn.Visibility = Visibility.Collapsed;
            }
        }

        private void BackBtn_Click(object sender, RoutedEventArgs e)
        {
            PChanger.MainFrame.GoBack();
        }

        private void ExitBtn_Click(object sender, RoutedEventArgs e)
        {
            AuthorizationWindow authorization = new AuthorizationWindow();
            authorization.Show();
            this.Close();
        }

        private void ChangeLogPasBtn_Click(object sender, RoutedEventArgs e)
        {
            ChangePasLogWindow changePasLog = new ChangePasLogWindow(_user);
            changePasLog.ShowDialog();
            PChanger.MainFrame.Refresh();
        }
    }
}
