/// <summary> /// Selects a certain type of a dish from populated dishList and prints it on the screen. /// </summary> /// <param name="dishType">String naming the dish type.</param> public void SelectDishes(DishTypes dishType) { if (Page_Frame.Visibility == Visibility.Visible) { Page_Frame.Visibility = Visibility.Hidden; Dish_Menu_ScrollViever.Visibility = Visibility.Visible; } if (dishType != currentlySelectedType) { selectedDishList.Clear(); ClearButtons(); foreach (var dish in dishList) { if (dish.Type == dishType.ToString()) { selectedDishList.Add(dish); } } PrintButtons(); currentlySelectedType = dishType; } }
public ActionResult DeleteConfirmed(int id) { DishTypes dishTypes = db.DishTypes.Find(id); db.DishTypes.Remove(dishTypes); db.SaveChanges(); return(RedirectToAction("Index")); }
public Dish(int dishcode, string name, DishTypes type, double price, string desc) { DishCode = dishcode; Name = name; Type = type; Price = price; Desc = desc; DishDict.Add(DishCode, this); }
public ActionResult Edit([Bind(Include = "Id,Name")] DishTypes dishTypes) { if (ModelState.IsValid) { db.Entry(dishTypes).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dishTypes)); }
public ActionResult Create([Bind(Include = "Id,Name")] DishTypes dishTypes) { if (ModelState.IsValid) { db.DishTypes.Add(dishTypes); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dishTypes)); }
public Dish GetDish(TimeOfDay timeOfDay, DishTypes dishType) { var dishes = this.GetDishesByTimeOfDay(timeOfDay); var dish = dishes.FirstOrDefault(_ => _.DishType == dishType); if (dish == null) { throw new InvalidOrderException($"Menu does not have ${dishType} at ${timeOfDay}"); } return(dish); }
// GET: DishTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DishTypes dishTypes = db.DishTypes.Find(id); if (dishTypes == null) { return(HttpNotFound()); } return(View(dishTypes)); }
public void EditDish(string name = "", DishTypes?type = null, double price = -1, string desc = null) { if (name != "") { Name = name; } if (type != null) { Type = (DishTypes)type; } if (price != -1) { Price = price; } if (desc != null) { Desc = desc; } }
public static Dish CreateDishFromConsole() { int dishcode = GenerateDishCode(); Write("Give the name of the new dish: "); string name = ReadLine(); Write("Give the type of the new dish: "); DishTypes type = (DishTypes)Enum.Parse(typeof(DishTypes), ReadLine()); double price = 0; do { Write("Give the price of the new dish: "); }while (!double.TryParse(ReadLine(), out price)); Write("Give the description of the new dish: "); string desc = ReadLine(); return(new Dish(dishcode, name, type, price, desc)); }
public Dish Find(TimeOfDay timeOfDay, DishTypes dishType) { return(this.All().FirstOrDefault(_ => _.TimeOfDay == timeOfDay && _.DishType == dishType)); }
public Dish(string name, DishTypes type, double price, string desc) : this(GenerateDishCode(), name, type, price, desc) { }