예제 #1
0
        /// <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;
            }
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            DishTypes dishTypes = db.DishTypes.Find(id);

            db.DishTypes.Remove(dishTypes);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
 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);
 }
예제 #4
0
 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));
 }
예제 #5
0
        public ActionResult Create([Bind(Include = "Id,Name")] DishTypes dishTypes)
        {
            if (ModelState.IsValid)
            {
                db.DishTypes.Add(dishTypes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dishTypes));
        }
예제 #6
0
        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);
        }
예제 #7
0
        // 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));
        }
예제 #8
0
 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;
     }
 }
예제 #9
0
        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));
        }
예제 #10
0
 public Dish Find(TimeOfDay timeOfDay, DishTypes dishType)
 {
     return(this.All().FirstOrDefault(_ => _.TimeOfDay == timeOfDay && _.DishType == dishType));
 }
예제 #11
0
 public Dish(string name, DishTypes type, double price, string desc) : this(GenerateDishCode(), name, type, price, desc)
 {
 }