Beispiel #1
0
        public bool Create(IDish dish)
        {
            var dishDic = new Dictionary <string, object> {
                { "Name", dish.Name }
            };

            var success = HelpFunctions.nonQuery("Dish_Insert", dishDic);


            if (success)
            {
                foreach (var dishData in dish.ArticleDishes)
                {
                    var articleDishDic = new Dictionary <string, object>();
                    articleDishDic.Add("Amount", dishData.Amount);
                    articleDishDic.Add("Article_Id", dishData.Article.Id);
                    articleDishDic.Add("Dish_Id", Read(dish));
                    HelpFunctions.nonQuery("ArticleDish_Insert", articleDishDic);
                }
            }

            InstantiateContextSQL();

            return(success);
        }
Beispiel #2
0
 public RestaurantsController(IRestaurant context, IDish dish, ICategory cat, IMenu menu)
 {
     this._restRepo = context;
     this._dishRepo = dish;
     this._catRepo  = cat;
     this._menuRepo = menu;
 }
Beispiel #3
0
 public DishesController(IDish dish, IRestaurant rest, ICategory cat, IMenu menu)
 {
     _dishRepo      = dish;
     this._restRepo = rest;
     this._catRepo  = cat;
     this._menuRepo = menu;
 }
Beispiel #4
0
        public void UpdateDish(int restaurantId, int dishId, IDish dish)
        {
            RestaurantEntity restaurantEntity = _dbContext
                                                .Restaurants
                                                .Include(r => r.Dishes)
                                                .FirstOrDefault(r => r.Id == restaurantId);

            if (restaurantEntity is null)
            {
                throw new NotFoundException("Restaurant not found.");
            }

            DishEntity dishEntity = restaurantEntity
                                    .Dishes
                                    .FirstOrDefault(d => d.Id == dishId);

            if (dishEntity is null)
            {
                throw new NotFoundException("Dish not found.");
            }

            dishEntity = _mapper.Map(dish, dishEntity);
            _dbContext.Dishes.Update(dishEntity);
            _dbContext.SaveChanges();
        }
Beispiel #5
0
        public Decorator(IDish <EType> decoratedObj, double price, double quantity, List <string> ingredients)
        {
            Quantity += quantity;
            Price    += price;

            DecoratedObj = decoratedObj;
            SetDish(price, quantity, ingredients);
        }
Beispiel #6
0
 public void Add(IDish dish)
 {
     dbContext.Dishes.Add(new Dish()
     {
         Name = dish.Name
     });
     dbContext.SaveChanges();
 }
Beispiel #7
0
 public void AddSalt(IDish dish)
 {
     dish.Salt++;
     // first thing to notice: mutation, this method is not thread safe,
     // and not even any method reading from dish.Salt at this point!
     // the answer is not "fixing mutation" by adding Monitor.TryEnter or lock { } construct!!!
     System.Console.WriteLine("we added salt!");
 }
Beispiel #8
0
 public void AddPepper(IDish dish)
 {
     dish.Pepper++;
     System.Console.WriteLine("we added salt!");
     // this method was created using copy-paste from the previous one: shame!
     // we can see it because the comment is still the old one! it happens, really.
     // ctrl-c tarararara ctrl-v! damn : )
 }
Beispiel #9
0
 public PizzaExtraTomatoesDecorator(IDish <EPizzaType> decoratedObj) :
     base(
         decoratedObj,
         Constants.PizzaExtraTomatoesPrice,
         Constants.PizzaExtraTomatoesQuantity,
         new List <string>(Constants.PizzaExtraTomatoesIngredients)
         )
 {
 }
Beispiel #10
0
        public void SaveDish(IDish dish)
        {
            if (dish == null)
            {
                throw new ArgumentNullException(nameof(dish));
            }

            _dishRepository.Save(dish);
        }
        protected override void AddSpecific(IDish dish, Topping?optionalTopping = null)
        {
            if (!optionalTopping.HasValue)
            {
                throw new ArgumentNullException(nameof(optionalTopping));
            }

            dish.Topping = optionalTopping.Value;
        }
Beispiel #12
0
 public SaladExtraSpicyDressingDecorator(IDish <ESaladType> decoratedObj) :
     base(
         decoratedObj,
         Constants.SaladExtraSpicyDressingPrice,
         Constants.SaladExtraSpicyDressingQuantity,
         new List <string>(Constants.SaladExtraSpicyDressingIngredients)
         )
 {
 }
 public PizzaExtraBaconDecorator(IDish <EPizzaType> decoratedObj) :
     base(
         decoratedObj,
         Constants.PizzaExtraBaconPrice,
         Constants.PizzaExtraBaconQuantity,
         new List <string>(Constants.PizzaExtraBaconIngredients)
         )
 {
 }
 public SaladExtraMozzarellaDecorator(IDish <ESaladType> decoratedObj) :
     base(
         decoratedObj,
         Constants.SaladExtraMozzarellaPrice,
         Constants.SaladExtraMozzarellaQuantity,
         new List <string>(Constants.SaladExtraMozzarellaIngredients)
         )
 {
 }
Beispiel #15
0
 public DrinkExtraLemonDecorator(IDish <EDrinkType> decoratedObj) :
     base(
         decoratedObj,
         Constants.DrinkExtraLemonPrice,
         Constants.DrinkExtraLemonQuantity,
         new List <string>(Constants.DrinkExtraLemonIngredients)
         )
 {
 }
 public PizzaChickenDecorator(IDish <EPizzaType> decoratedObj) :
     base(
         decoratedObj,
         EPizzaType.CHICKEN,
         Constants.PizzaChickenPrice,
         Constants.PizzaChickenQuantity,
         new List <string>(Constants.PizzaChickenIngredients)
         )
 {
 }
Beispiel #17
0
 public SaladVegetarianDecorator(IDish <ESaladType> decoratedObj) :
     base(
         decoratedObj,
         ESaladType.VEGETARIAN,
         Constants.SaladVegetarianPrice,
         Constants.SaladVegetarianQuantity,
         new List <string>(Constants.SaladVegetarianIngredients)
         )
 {
 }
Beispiel #18
0
 public Dish(IDish dish, DateTime dt, IList <DishItem> _DishItems)
 {
     WeightDish                  = dish.WeightDish;
     DishItems                   = _DishItems;
     NumberDoc                   = dish.NumberDoc;
     DateCreate                  = dt;
     NameDish                    = dish.NameDish;
     ExpandedNameDish            = dish.ExpandedNameDish;
     NumberInCollectionOfRecipes = dish.NumberInCollectionOfRecipes;
 }
Beispiel #19
0
 public SaladMediterraneanDecorator(IDish <ESaladType> decoratedObj) :
     base(
         decoratedObj,
         ESaladType.MEDITERRANEAN,
         Constants.SaladMediterraneanPrice,
         Constants.SaladMediterraneanQuantity,
         new List <string>(Constants.SaladMediterraneanIngredients)
         )
 {
 }
 public PizzaCapricciosaDecorator(IDish <EPizzaType> decoratedObj) :
     base(
         decoratedObj,
         EPizzaType.CAPRICCIOSA,
         Constants.PizzaCapricciosaPrice,
         Constants.PizzaCapricciosaQuantity,
         new List <string>(Constants.PizzaCapricciosaIngredients)
         )
 {
 }
 public DrinkCherrySodaDecorator(IDish <EDrinkType> decoratedObj) :
     base(
         decoratedObj,
         EDrinkType.CHERRY_SODA,
         Constants.DrinkCherrySodaPrice,
         Constants.DrinkCherrySodaQuantity,
         new List <string>(Constants.DrinkCherrySodaIngredients)
         )
 {
 }
Beispiel #22
0
 public DrinkOrangeJuiceDecorator(IDish <EDrinkType> decoratedObj) :
     base(
         decoratedObj,
         EDrinkType.ORANGE_JUICE,
         Constants.DrinkOrangeJuicePrice,
         Constants.DrinkOrangeJuiceQuantity,
         new List <string>(Constants.DrinkOrangeJuiceIngredients)
         )
 {
 }
Beispiel #23
0
        /// <summary>
        ///
        ///     Create
        ///
        ///     Right    = Admin, Instructor
        ///
        ///     Exception     = validation
        ///
        /// </summary>
        public bool Add(int userId, IDish dish)
        {
            if (!UserLogic.CheckRight(userId, Right.Admin) || UserLogic.CheckRight(userId, Right.Instructor))
            {
                return(false);
            }


            return(_repository.Add(dish));
        }
 public PizzaDiavolaDecorator(IDish <EPizzaType> decoratedObj) :
     base(
         decoratedObj,
         EPizzaType.DIAVOLA,
         Constants.PizzaDiavolaPrice,
         Constants.PizzaDiavolaQuantity,
         new List <string>(Constants.PizzaDiavolaIngredients)
         )
 {
 }
Beispiel #25
0
 public DrinkColaDecorator(IDish <EDrinkType> decoratedObj) :
     base(
         decoratedObj,
         EDrinkType.COLA,
         Constants.DrinkColaPrice,
         Constants.DrinkColaQuantity,
         new List <string>(Constants.DrinkColaIngredients)
         )
 {
 }
 public SaladCaesarDecorator(IDish <ESaladType> decoratedObj) :
     base(
         decoratedObj,
         ESaladType.CAESAR,
         Constants.SaladCaesarPrice,
         Constants.SaladCaesarQuantity,
         new List <string>(Constants.SaladCaesarIngredients)
         )
 {
 }
Beispiel #27
0
        private static DishDto InterfaceToDto(IDish dish)
        {
            var dishDto = new DishDto
            {
                Id            = dish.Id,
                Name          = dish.Name,
                ArticleDishes = dish.ArticleDishes
            };

            return(dishDto);
        }
 public Handler(
     IUserAuth userAuth,
     IDish dish,
     IIngredient ingredient,
     IRecipe recipe)
 {
     _ingredient = ingredient;
     _recipe     = recipe;;
     _dish       = dish;
     _userAuth   = userAuth;
 }
Beispiel #29
0
        public bool Update(IDish dish)
        {
            var parameters = new Dictionary <string, object>
            {
                { "Id", dish.Id },
                { "Name", dish.Name }
            };

            InstantiateContextSQL();

            return(HelpFunctions.nonQuery("Dish_Update", parameters));
        }
Beispiel #30
0
        public void UpdateDish(IDish dish)
        {
            if (dish == null)
            {
                throw new ArgumentNullException(nameof(dish));
            }

            var existingDish = GetDish(dish.id);

            UpdateDishFields(existingDish, dish);

            _dishDataAccess.SaveDish(existingDish);
        }
Beispiel #31
0
 public bool IsCorrect(IDish dish, int? pos = null)
 {
     return rs.Take(pos.Value).Any(t =>
         (t.Dish.Name.ToLower() != "coffee" || t.Dish.Name.ToLower() != "potato") && t.Dish.TypeId == dish.TypeId);
 }
 public bool IsCorrect(IDish dish, int? pos = null)
 {
     return (dish.TypeId == 4 && dish.TimeofDay == "night");
 }