private static void CreateDessertDictionary() { dessertDictionary = new Dictionary <DessertType, Dessert>(); DessertType[] dessertTypes = new DessertType[] { DessertType.ChocolateCake, DessertType.Brownie, DessertType.Bonbon, DessertType.PeanutButterBonbon, DessertType.VanillaCannoli, DessertType.ChocolateCannoli, DessertType.HalfAndHalfCannoli, DessertType.AppleCrumbCheesecake, DessertType.SnickerDoodleCookie, DessertType.ChocolateChipCookie, DessertType.PeanutButterCookie, DessertType.OatmealRaisinCookie, DessertType.MexicanWeddingCookie, DessertType.PumpkinSpiceCookie, DessertType.VeganPumpkinSpiceCookie, DessertType.WholeCake //DessertType.AnyCookie, //DessertType.VeganDessert, //DessertType.ThreeDollarDessert }; foreach (var dessertType in dessertTypes) { Dessert newDessert = new Dessert(dessertType); dessertDictionary.Add(dessertType, newDessert); } }
private void showDessert(Dessert i_Dessert) { errorText.Text = ""; quantityText.Text = ""; severalDinerText.Text = ""; currentListBox.Items.Insert(currentListBox.Items.Count, i_Dessert); }
public IFood Create(string type, string name, decimal price) { IFood food = null; switch (type) { case "Dessert": food = new Dessert(name, price); break; case "MainCourse": food = new MainCourse(name, price); break; case "Salad": food = new Salad(name, price); break; case "Soup": food = new Soup(name, price); break; } return(food); }
public void Seed() { Entree firstEntree = new Entree("Vegan Rice", "Blend of vegan ingredients", 7.50m, IngredientsType.Tofu, IngredientsType.BrownRice, IngredientsType.Onions, IngredientsType.VeganCheese); Entree secondEntree = new Entree("Chicken and Bacon Salad", "Salad with fresh ingredients", 7.50m, IngredientsType.Chicken, IngredientsType.Spinach, IngredientsType.Bacon, IngredientsType.Cheese); Side firstSide = new Side("Vegan Salad", "Salad with vegan cheese and delicious tofu", 4.99m, IngredientsType.Tofu, IngredientsType.Spinach, IngredientsType.Onions, IngredientsType.VeganCheese); Side secondSide = new Side("Fried Rice", "Fried rice with beef", 4.99m, IngredientsType.Beef, IngredientsType.WhiteRice, IngredientsType.Onions, IngredientsType.NA); Dessert firstDessert = new Dessert("Fudge Brownie Sundae", "Warm brownie, cold icecream", 3.99m, DessertIngredientsType.IceCream, DessertIngredientsType.Brownie, DessertIngredientsType.Caramel); Dessert secondDessert = new Dessert("Cookies and Cream", "Whipped Cream stuff cookie", 3.99m, DessertIngredientsType.Cookie, DessertIngredientsType.WhipCream, DessertIngredientsType.Chocolate); Dessert thirdDessert = new Dessert("Vegan dessert", "Animal cruetly free dessert", 3.99m, DessertIngredientsType.RicePudding, DessertIngredientsType.Chocolate, DessertIngredientsType.Caramel); Drink firstDrink = new Drink("Chocolate shake", 3.99m, DrinkType.Regular); Drink secondDrink = new Drink("Irish Coffee", 5.99m, DrinkType.Regular); MenuItems firstMeal = new MenuItems(1, "Vegan meal", "Enjoy specially created meals with no animal cruelty", firstEntree, firstSide, thirdDessert); MenuItems secondMeal = new MenuItems(2, "Chicken and Bacon Ranch", "Enjoy our classic CBR", secondEntree, secondSide, firstDessert); _entrees.AddEntreesToDirectory(firstEntree); _entrees.AddEntreesToDirectory(secondEntree); _sides.AddSidesToDirectory(firstSide); _sides.AddSidesToDirectory(secondSide); _desserts.AddDessertsToDirectory(firstDessert); _desserts.AddDessertsToDirectory(secondDessert); _desserts.AddDessertsToDirectory(thirdDessert); _drinks.AddDrinksToDirectory(firstDrink); _drinks.AddDrinksToDirectory(secondDrink); _menu.AddMealsToDirectory(firstMeal); _menu.AddMealsToDirectory(secondMeal); }
public void GetMealsByNumberAndItemsByName() { Entree searchEntree = _entrees.GetEntreesByName("Vegan Rice"); Side searchSide = _sides.GetSidesByName("Vegan Salad"); Dessert searchDessert = _desserts.GetDessertsByName("Fudge Brownie Sundae"); Drink searchDrink = _drinks.GetDrinksByName("Chocolate shake"); MenuItems searchMeal = _menu.GetMenuItemsByNumber(1); string expectedEntree = "Vegan Rice"; string actualEntree = searchEntree.Name; string expexectedSide = "Vegan Salad"; string actualSide = searchSide.Name; string expectedDessert = "Fudge Brownie Sundae"; string actualDessert = searchDessert.Name; string expectedDrink = "Chocolate shake"; string actualDrink = searchDrink.Name; int expectedMeal = 1; int actualMeal = searchMeal.MealNum; Assert.AreEqual(expectedEntree, actualEntree); Assert.AreEqual(expexectedSide, actualSide); Assert.AreEqual(expectedDessert, actualDessert); Assert.AreEqual(expectedDrink, actualDrink); Assert.AreEqual(expectedMeal, actualMeal); }
void NavigateToDessertPage(Dessert dessertForEdit) { var currentMainPage = Application.Current.MainPage as MasterDetailPage; currentMainPage.Detail = new NavigationPage(new DessertPage(dessertForEdit)); Application.Current.MainPage = currentMainPage; }
public string AddFood(string type, string name, decimal price) { IFood food = null; string output = string.Empty; if (type == "Dessert") { food = new Dessert(name, price); menu.Add(food); output = $"Added {name} ({type}) with price {price:f2} to the pool"; } else if (type == "MainCourse") { food = new MainCourse(name, price); menu.Add(food); output = $"Added {name} ({type}) with price {price:f2} to the pool"; } else if (type == "Salad") { food = new Salad(name, price); menu.Add(food); output = $"Added {name} ({type}) with price {price:f2} to the pool"; } else if (type == "Soup") { food = new Soup(name, price); menu.Add(food); output = $"Added {name} ({type}) with price {price:f2} to the pool"; } return(output); }
public void KitchenOrder() { Order order = new Order(); FoodItem dessert = new Dessert("Chocolate Decadence"); FoodItem entree = new Entree("Beef Oscar"); FoodItem salad = new Salad("Parmesan Peppercorn"); // Add out of order order.AddFoodItem(dessert); order.AddFoodItem(entree); order.AddFoodItem(salad); // But should come out in serving order IEnumerator <FoodItem> itr = order.GetEnumerator(); Assert.That(salad, Is.EqualTo(itr.Current)); itr.MoveNext(); Assert.That(entree, Is.EqualTo(itr.Current)); itr.MoveNext(); Assert.That(dessert, Is.EqualTo(itr.Current)); itr.MoveNext(); // No more left Assert.That(itr.MoveNext(), Is.False); }
/////////////////////////////////////////////////////////////REQUÊTE AFIN DE RECUPERER LES DESSERTS /////////////////////////////////////////////////////////////////////////////////////////////// public static List <Dessert> getLesDesserts(string daterequete) { List <Dessert> lesDesserts = new List <Dessert>(); try { MySqlConnection cnx = MySQL.getCnx(); cnx.Ping(); string requete = "SELECT DES_ID, DES_LIBELLE, DES_DESCRIPTION FROM dessert, repasdessert, repas WHERE DES_ID=RD_DESSERT AND RD_REPAS=REP_ID AND REP_DATE= '" + daterequete + "' "; MySqlCommand cmd = new MySqlCommand(requete, cnx); var reader = cmd.ExecuteReader(); while (reader.Read()) { Dessert unDessert = new Dessert(); unDessert.Id = reader.GetInt32(0); unDessert.Libelle = reader.GetString(1); unDessert.Description = reader.GetString(2); lesDesserts.Add(unDessert); } cnx.Close(); return(lesDesserts); } catch (MySqlException ex) { Dessert erreurSQL = new Dessert(); erreurSQL.Description = (ex.ToString()); lesDesserts.Add(erreurSQL); return(lesDesserts); } }
public AddDessertViewModel AddModel(Dessert item) { //目前選擇的點心 List <AddDessertViewModel> allCout = Session["DessertCount"] as List <AddDessertViewModel>; int Amount = 0; //判斷是否有選擇過此點心則讀取Session if (allCout != null) { //取出目前要顯示的點心 var dessertCount = allCout.Where(x => x.DessertID == item.DessertID); //若數量>0則顯示數量 if (dessertCount.Count() > 0) { Amount = dessertCount.FirstOrDefault().DessertAmount; } } //回傳單一點心資料 return(new AddDessertViewModel() { DessertID = item.DessertID, DessertImage = item.DessertImage, DessertIntroduction = item.DessertIntroduction, DessertKind = item.DessertKind, DessertName = item.DessertName, DessertPrice = item.DessertPrice, DessertAmount = Amount }); }
public MainWindow() { InitializeComponent(); Essen.Menus = Steuerelemente.Menus.e_Essen; Getränke.Menus = Steuerelemente.Menus.e_Getränke; Dessert.Menus = Steuerelemente.Menus.e_Desserts; Beilagen.Menus = Steuerelemente.Menus.e_Beilagen; // Blendet alle Fenster aus bis auf das Essens Fenster Essen.Visibility = Visibility.Visible; Getränke.Visibility = Visibility.Hidden; Dessert.Visibility = Visibility.Hidden; Beilagen.Visibility = Visibility.Hidden; // Fügt die verschiedenen Fenster zum window manager hinzu sodass diese besser verwaltete werden können WindowManager.MainWindow = this; WindowManager.EssenWindow = Essen; WindowManager.GetränkeWindow = Getränke; WindowManager.DessertWindow = Dessert; WindowManager.BeilagenWindow = Beilagen; WindowManager.RechnungsManagerWindow = m_RechnungsManager; // An dieser stelle werden die Produkte in die verschiedenen Fenster geladen und Knöpfe dynamisch erstellt. Essen.Init(Core.ProductManager.GetManager().Essen); Getränke.Init(Core.ProductManager.GetManager().Getränke); Dessert.Init(Core.ProductManager.GetManager().Dessert); Beilagen.Init(Core.ProductManager.GetManager().Beilagen); // Sichtbarkeit für die Größen auswahl der Getränke ausgeblenden SizeSmall.Visibility = Visibility.Hidden; SizeMedium.Visibility = Visibility.Hidden; SizeLarge.Visibility = Visibility.Hidden; }
public async Task <IActionResult> EditDessert([FromBody] DessertInfo dessertInfo) { string emailAddress = HttpContext.User.Identity.Name; var restaurant = await _context.Restaurant .Where(rest => rest.EmailAddress.Equals(emailAddress)) .FirstOrDefaultAsync(); string dessertName = Request.Headers["dessertName"]; Dessert dessertToUpdate = await _context.Dessert .Where(d => d.Name.Equals(dessertName)) .FirstOrDefaultAsync(); dessertToUpdate.Name = dessertInfo.Name; dessertToUpdate.Price = dessertInfo.Price; dessertToUpdate.Description = dessertInfo.Description; dessertToUpdate.HouseSpecial = dessertInfo.HouseSpecial; if (ModelState.IsValid) { try { _context.Update(dessertToUpdate); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } } HttpContext.Response.StatusCode = 200; return(new JsonResult("Dessert successfully updated")); }
public async Task <IActionResult> Edit(int id, [Bind("Milliliter,IsFrozen,ProductID,Name,Price,Description,Stockpiled")] Dessert dessert) { if (id != dessert.ProductID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dessert); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DessertExists(dessert.ProductID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(dessert)); }
public string AddFood(string type, string name, decimal price) { IFood food = null; switch (type.ToLower()) { case "dessert": food = new Dessert(name, price); break; case "salad": food = new Salad(name, price); break; case "soup": food = new Soup(name, price); break; case "maincourse": food = new MainCourse(name, price); break; default: throw new ArgumentException($"Invalid food type {type}!"); } this.menu.Add(food); return($"Added {food.Name} ({type}) with price {food.Price:f2} to the pool"); }
//[ValidateAntiForgeryToken] public async Task <JsonResult> CreateDessert([FromBody] DessertInfo dessertInfo) { string emailAddress = HttpContext.User.Identity.Name; var restaurant = await _context.Restaurant .Where(rest => rest.EmailAddress.Equals(emailAddress)) .FirstOrDefaultAsync(); if (checkDessertNameInSameRestaurant(dessertInfo.Name, restaurant.Id)) { HttpContext.Response.StatusCode = 400; return(new JsonResult("Dessert " + dessertInfo.Name + " already exists in restaurant")); } Dessert newDessert = new Dessert { Name = dessertInfo.Name, Description = dessertInfo.Description, Price = dessertInfo.Price, HouseSpecial = dessertInfo.HouseSpecial }; if (ModelState.IsValid) { newDessert.RestaurantId = restaurant.Id; _context.Add(newDessert); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index), new { id = id }); } HttpContext.Response.StatusCode = 200; return(new JsonResult("Dessert successfully created")); }
public IFood CreateFood(string type, string name, decimal price) { IFood food = null; if (type == "Dessert") { food = new Dessert(name, price); } else if (type == "Salad") { food = new Salad(name, price); } else if (type == "Soup") { food = new Soup(name, price); } else if (type == "MainCourse") { food = new MainCourse(name, price); } else { throw new InvalidOperationException("Invalid food type!"); } return(food); }
public string AddFood(string type, string name, decimal price) { IFood food = null; if (type == "Dessert") { food = new Dessert(name, price); } else if (type == "Salad") { food = new Salad(name, price); } else if (type == "Soup") { food = new Soup(name, price); } else if (type == "MainCourse") { food = new MainCourse(name, price); } if (food != null) { this.menu.Add(food); } return($"Added {food.Name} ({food.GetType().Name}) with price {food.Price:F2} to the pool"); }
public string AddFood(string type, string name, decimal price) { IFood food = null; switch (type) { case "Dessert": food = new Dessert(name, price); break; case "MainCourse": food = new MainCourse(name, price); break; case "Salad": food = new Salad(name, price); break; case "Soup": food = new Soup(name, price); break; } menu.Add(food); return($"Added {name} ({type}) with price {price:f2} to the pool"); }
private void Tb_image_MouseDown(object sender, MouseButtonEventArgs e) { if (lbDesserts.SelectedIndex != -1) { Dessert dessert = lbDesserts.SelectedItem as Dessert; LoadImage(dessert); } }
public Cheff(RestaurantFactory restaurantFactory) { this.restaurantFactory = restaurantFactory; this.soup = restaurantFactory.CreateSoup(); this.meal = restaurantFactory.CreateMeal(); this.dessert = restaurantFactory.CreateDessert(); }
public ActionResult DeleteConfirmed(int id) { Dessert dessert = db.Desserts.Find(id); db.Desserts.Remove(dessert); db.SaveChanges(); return(RedirectToAction("Index")); }
public void SetUp() { _dessert = new Dessert { Id = 3, Name = "Petit Gateau", Price = 20.99, Description = "Small chocolate cake with crispy shell and creamy filling served usually accompanied by ice cream" }; _mockOptionPrepare = new Mock <BaseOptionPrepare>(); _mockOptionPrepare.Setup(_ => _.IsOptionActive).Returns(true); }
public ActionResult <Dessert> PostDessert(Dessert dessert) { Dessert dessertToCreate = new Dessert(dessert.Naam, dessert.Prijs, dessert.Hoeveelheid, dessert.Omschrijving, dessert.Foto); _dessertsRepository.Add(dessertToCreate); _dessertsRepository.SaveChanges(); //201 + link naar gecreeerd dessert + optioneel het gecreerde dessert return(CreatedAtAction(nameof(GetDessert), new { id = dessertToCreate.Id }, dessertToCreate)); }
public ActionResult Edit([Bind(Include = "DessertId,DessertName,DessertShortDescription,DessertLongDescription,DessertPrice,DessertImage")] Dessert dessert) { if (ModelState.IsValid) { // db.Entry(dessert).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dessert)); }
public ActionResult Edit([Bind(Include = "Id,Title,Dietary,Ingredients,CookTime,PrepTime,RecipeMethod,Servings,DessertArtUrl,Like,Dislikes,User")] Dessert dessert) { if (ModelState.IsValid) { db.Entry(dessert).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dessert)); }
public static void Main(string[] args) { Product ddd = new Dessert("tolumba", 5, 5, 1000); System.Console.WriteLine($"{ddd.Name} за {ddd.Price} леа"); System.Console.WriteLine($"{ddd.Name} за {ddd.Price} леа"); System.Console.WriteLine($"{ddd.Name} за {ddd.Price} леа"); System.Console.WriteLine($"{ddd.Name} за {ddd.Price} леа"); System.Console.WriteLine($"{ddd.Name} за {ddd.Price} леа"); }
//public static Order ConvertDbCheckToOrder(DBCheck check, decimal tableId, decimal[] guestIds) //{ // //var openOrder = new Order(tableId) // //{ // // IsTakeout = false, // // GuestIds = guestIds // //}; // //foreach (var item in check.Items) // //{ // // var openOrderItem = OrderItemFactory.GetOrderItem(item); // // openOrder.AddItemToOrder(openOrderItem); // //} // //return openOrder; //} public static Dessert GetDessert(GuestItem oldGuestItem) { Dessert newDessert = MenuFood.GetDessertFromMenu(oldGuestItem.ID); newDessert.DbItemId = oldGuestItem.ID; newDessert.WasSentToKitchen = oldGuestItem.OrderSent; newDessert.DbOrderId = (int)oldGuestItem.OrderID; newDessert.ItemCount = 1; return(newDessert); }
public ActionResult Edit([Bind(Include = "Id,Item,Description,Image,Price")] Dessert dessert) { if (ModelState.IsValid) { db.Entry(dessert).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dessert)); }
/// <summary> /// 按照編號尋找點心 /// </summary> /// <param name="id"></param> /// <returns></returns> public Dessert GetDessertById(int id) { Dessert selectedDessert = allDessert.SingleOrDefault(context => context.id == id); if (selectedDessert == null) { throw new ArgumentException(String.Format("Dessert ID {0} 不正確", id)); } return(selectedDessert); }
public void Update(Dessert toUpdateDessert) { var dessert = _desserts.FirstOrDefault(d => d.Id == toUpdateDessert.Id); if (dessert != null) { _context.Update(dessert); } //_context.Update(toUpdateMenu); }