public CompleteMeal(Cook cook, Eater eater)
 {
     InitializeComponent();
     dbAccess                  = SingletonDatabaseAccess.DBInstance;
     this.currentCook          = cook;
     this.currentEater         = eater;
     this.lblCookName.Content  = currentCook.Name;
     this.lblEaterName.Content = currentEater.Name;
     this.lblEaterCity.Content = currentEater.City;
 }
 public EaterWindow(Eater eater)
 {
     InitializeComponent();
     currentEater = eater;
     Console.WriteLine("Meal offers = " + Eater.MealOffers);
     if (Eater.MealOffers > 0)
     {
         var response = MessageBox.Show("One of the cooks has sent you an offer", "Awaiting Meal Offer", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (response == MessageBoxResult.Yes)
         {
             Eater.MealOffers--;
             Console.WriteLine("Meal offers after = " + Eater.MealOffers);
         }
     }
 }
 private void btnSubmit_Eater_Click(object sender, RoutedEventArgs e)
 {
     eaterAccount             = new Eater();
     eaterAccount.Name        = txtEaterName.Text;
     eaterAccount.PhoneNumber = txtEaterPhone.Text;
     eaterAccount.Age         = Int32.Parse(txtEaterAge.Text);
     if (cmbChooseDisability.SelectedIndex == 0)
     {
         eaterAccount.HasDisability = true;
     }
     eaterAccount.City            = txtCityEater.Text;
     eaterAccount.MealPreferences = txtMealPreferencesEater.Text;
     dbAccess.EatersDB.Add(eaterAccount);
     savingAccountAndClosingWindow(e);
 }
        private void completeMealWindowOpen()
        {
            String nameToFind = Regex.Match(listUpcomingMeals.SelectedItem.ToString(), @"^([A-Za-z]+)").Value;

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

            foreach (Eater cook in dbAccess.EatersDB)
            {
                selectedEater = dbAccess.EatersDB.Find(c => c.Name == nameToFind);
            }
            CompleteMeal completeMealWindow = new CompleteMeal(currentCook, selectedEater);

            completeMealWindow.Owner = this;
            completeMealWindow.ShowDialog();
        }
        private void sendMealOfferWindowOpen()
        {
            String nameToFind = Regex.Match(listAvailableEaters.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: ", "");
            Console.WriteLine("Name to find is " + nameToFind);
            selectedEater = new Eater();

            foreach (Eater cook in dbAccess.EatersDB)
            {
                selectedEater = dbAccess.EatersDB.Find(c => c.Name == nameToFind);
            }
            SendMealOffer sendMealOfferWindow = new SendMealOffer(currentCook, selectedEater);

            sendMealOfferWindow.Owner = this;
            sendMealOfferWindow.ShowDialog();
        }
        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 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");
            }
        }