public MainWindow() { InitializeComponent(); breakfastMenu = new Menus.Menus(Menus.MealChoice.Breakfast); lunchMenu = new Menus.Menus(Menus.MealChoice.Lunch); dinnerMenu = new Menus.Menus(Menus.MealChoice.Dinner); int legalDrinkingAge = Convert.ToInt32(ConfigurationManager.AppSettings["LegalDrinkingAge"]); todaysDateTextBlock.Text = DateTime.Now.ToShortDateString(); bornByDateTextBlock.Text = DateTime.Now.AddYears(legalDrinkingAge * -1).ToShortDateString(); }
private void diningSelection_Checked(object sender, RoutedEventArgs e) { var button = sender as RadioButton; menuListBox.Items.Clear(); drinkListBox.Items.Clear(); Random random = new Random(); switch (button.Name) { case "breakfastRadioButton": foreach (var menuItem in breakfastMenu.MealMenu) { menuListBox.Items.Add(menuItem.itemName + "\r\n" + menuItem.itemCost.ToString("C2")); } menuSpecialIndex = random.Next(0, breakfastMenu.MealMenu.Count); dailySpecialTextblock.Text = String.Format("Today's special is -\r\n {0} \r\n {1}", breakfastMenu.MealMenu.ElementAt(menuSpecialIndex).itemName, (breakfastMenu.MealMenu.ElementAt(menuSpecialIndex).itemCost *(1 - dailySpecialDiscount)).ToString("C2")); foreach (var menuItem in breakfastMenu.DrinkMenu) { drinkListBox.Items.Add(menuItem.itemName + menuItem.itemRestriction + "\r\n" + menuItem.itemCost.ToString("C2")); } selectedMenus = breakfastMenu; break; case "lunchRadioButton": foreach (var menuItem in lunchMenu.MealMenu) { menuListBox.Items.Add(menuItem.itemName + "\r\n" + menuItem.itemCost.ToString("C2")); } menuSpecialIndex = random.Next(0, lunchMenu.MealMenu.Count()); dailySpecialTextblock.Text = String.Format("Today's special is -\r\n {0} \r\n {1}", lunchMenu.MealMenu.ElementAt(menuSpecialIndex).itemName, (lunchMenu.MealMenu.ElementAt(menuSpecialIndex).itemCost * .9).ToString("C2")); foreach (var menuItem in lunchMenu.DrinkMenu) { drinkListBox.Items.Add(menuItem.itemName + menuItem.itemRestriction + "\r\n" + menuItem.itemCost.ToString("C2")); } selectedMenus = lunchMenu; break; case "dinnerRadioButton": foreach (var menuItem in dinnerMenu.MealMenu) { menuListBox.Items.Add(menuItem.itemName + "\r\n" + menuItem.itemCost.ToString("C2")); } menuSpecialIndex = random.Next(0, dinnerMenu.MealMenu.Count()); dailySpecialTextblock.Text = String.Format("Today's special is -\r\n {0} \r\n {1}", dinnerMenu.MealMenu.ElementAt(menuSpecialIndex).itemName, (dinnerMenu.MealMenu.ElementAt(menuSpecialIndex).itemCost * .9).ToString("C2")); foreach (var menuItem in dinnerMenu.DrinkMenu) { drinkListBox.Items.Add(menuItem.itemName + menuItem.itemRestriction + "\r\n" + menuItem.itemCost.ToString("C2")); } selectedMenus = dinnerMenu; break; } menuHeadingTextBlock.Text = String.Format("Your {0} selections - ", button.Content); mealSelection = button.Content.ToString(); ageRetrictionTextBlock.Text = " * - contains alcohol - age retrictions apply"; }