public CookWindow(Cook cook)
        {
            InitializeComponent();
            this.currentCook = cook;
            dbAccess         = SingletonDatabaseAccess.DBInstance;

            lblCookActiveSince.Content = currentCook.ActiveSince.ToShortDateString();
            lblCookName.Content        = currentCook.Name;
            lblCookCity.Content        = currentCook.City;

            if (currentCook.ValidPVG == Cook.pvg_hygiene_statuses.OK)
            {
                lblPVGstatusOK.Visibility = Visibility.Visible;
                readMeals();
            }
            else if (currentCook.ValidPVG == Cook.pvg_hygiene_statuses.AwaitingResults)
            {
                lblPVGstatusAwaiting.Visibility = Visibility.Visible;
                disableButtons();
            }
            else
            {
                lblPVGstatusBAD.Visibility = Visibility.Visible;
                disableButtons();
            }

            if (currentCook.ValidHygieneCertificate == Cook.pvg_hygiene_statuses.OK)
            {
                lblHygieneStatusOK.Visibility = Visibility.Visible;
                readMeals();
            }
            else if (currentCook.ValidHygieneCertificate == Cook.pvg_hygiene_statuses.RenevalWith3months)
            {
                lblHygieneStatusRenew.Visibility = Visibility.Visible;
                lblHygieneTitle.Visibility       = Visibility.Visible;
                lblCookRenewalDate.Visibility    = Visibility.Visible;
                lblCookRenewalDate.Content       = currentCook.HygieneRenevalDate.ToShortDateString();
                readMeals();
            }
            else
            {
                lblHygieneStatusBAD.Visibility = Visibility.Visible;
                lblHygieneTitle.Visibility     = Visibility.Visible;
                lblHygieneOverdue.Visibility   = Visibility.Visible;
                disableButtons();
            }
        }
        public SendMealOffer(Cook cook, Eater eater)
        {
            InitializeComponent();
            dbAccess          = SingletonDatabaseAccess.DBInstance;
            this.currentCook  = cook;
            this.currentEater = eater;
            //filling in the combobox with available times
            for (int i = 12; i < 20; i++)
            {
                cmbSetTime.Items.Add(i + ":00");
                cmbSetTime.Items.Add(i + ":30");
            }

            this.lblCookName.Content  = currentCook.Name;
            this.lblEaterName.Content = currentEater.Name;
            this.lblEaterCity.Content = currentEater.City;
            currentMealOffer          = new Meal();
        }
 private void btnSubmit_Cook_Click(object sender, RoutedEventArgs e)
 {
     cookAccount             = new Cook();
     cookAccount.Name        = txtCookName.Text;
     cookAccount.PhoneNumber = txtCookPhone.Text;
     if (cmbChoosePVG.SelectedIndex == 0)
     {
         cookAccount.ValidPVG = Cook.pvg_hygiene_statuses.OK;
     }
     else if (cmbChoosePVG.SelectedIndex == 1)
     {
         cookAccount.ValidPVG = Cook.pvg_hygiene_statuses.Rejected;
     }
     else
     {
         cookAccount.ValidPVG = Cook.pvg_hygiene_statuses.AwaitingResults;
         MessageBox.Show("In order to be able to share the meals you need to have valid PVG Certificate");
     }
     if (cmbChooseHygieneCertificate.SelectedIndex == 0)
     {
         cookAccount.ValidHygieneCertificate = Cook.pvg_hygiene_statuses.OK;
     }
     else
     {
         cookAccount.ValidHygieneCertificate = Cook.pvg_hygiene_statuses.None;
         MessageBox.Show("In order to be able to share the meals you need to have valid Hygiene Certificate and renew that when it is needed.");
     }
     cookAccount.City = txtCityCook.Text;
     if (cookAccount.ValidPVG == Cook.pvg_hygiene_statuses.OK && (cookAccount.ValidHygieneCertificate == Cook.pvg_hygiene_statuses.OK || cookAccount.ValidHygieneCertificate == Cook.pvg_hygiene_statuses.RenevalWith3months))
     {
         cookAccount.ActiveSince = DateTime.Today.Date;
         Console.WriteLine("Today is " + cookAccount.ActiveSince.Date);
     }
     dbAccess.CooksDB.Add(cookAccount);
     savingAccountAndClosingWindow(e);
 }
        private void btnLogIn_Click(object sender, RoutedEventArgs e)
        {
            String nameToFind = Regex.Match(cmbChooseAccount.SelectedItem.ToString(), @"Name: ([A-Za-z]+)").Value;

            //String nameToFind = Regex.Match(cmbChooseAccount.SelectedItem.ToString(), @"\bName\W+\s\w+\W+\s\b").Value;
            nameToFind = Regex.Replace(nameToFind, @"Name: ", "");
            //MessageBox.Show("Name to find is " + nameToFind);
            Console.WriteLine("Name to find is " + nameToFind);

            if (accountToLogIn == 1)
            {
                Cook currentCook = new Cook();
                foreach (Cook cook in dbAccess.CooksDB)
                {
                    currentCook = dbAccess.CooksDB.Find(c => c.Name == nameToFind);
                }

                if (passwordBox.Password == SingletonDatabaseAccess.PasswordForAll)
                {
                    CookWindow cookWindow = new CookWindow(currentCook);
                    this.Close();
                    cookWindow.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Please enter the valid password!");
                }
            }
            else if (accountToLogIn == 2)
            {
                Eater currentEater = new Eater();
                foreach (Eater eater in dbAccess.EatersDB)
                {
                    currentEater = dbAccess.EatersDB.Find(eat => eat.Name == nameToFind);
                }
                if (passwordBox.Password == SingletonDatabaseAccess.PasswordForAll)
                {
                    EaterWindow eaterWindow = new EaterWindow(currentEater);
                    this.Close();
                    eaterWindow.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Please enter the valid password!");
                }
            }
            else if (accountToLogIn == 3)
            {
                Administrator currentAdmin = new Administrator();
                foreach (Administrator admin in dbAccess.AdminsDB)
                {
                    currentAdmin = dbAccess.AdminsDB.Find(a => a.Name == nameToFind);
                }
                if (passwordBox.Password == SingletonDatabaseAccess.PasswordForAll)
                {
                    AdminWindow adminWindow = new AdminWindow(currentAdmin);
                    this.Close();
                    adminWindow.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Please enter the valid password!");
                }
            }
            else
            {
                MessageBox.Show("Please select one of the accounts from above to Log In");
            }
        }