Esempio n. 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);
        }
Esempio n. 2
0
 public RestaurantsController(IRestaurant context, IDish dish, ICategory cat, IMenu menu)
 {
     this._restRepo = context;
     this._dishRepo = dish;
     this._catRepo  = cat;
     this._menuRepo = menu;
 }
Esempio n. 3
0
 public DishesController(IDish dish, IRestaurant rest, ICategory cat, IMenu menu)
 {
     _dishRepo      = dish;
     this._restRepo = rest;
     this._catRepo  = cat;
     this._menuRepo = menu;
 }
Esempio n. 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();
        }
Esempio n. 5
0
        public Decorator(IDish <EType> decoratedObj, double price, double quantity, List <string> ingredients)
        {
            Quantity += quantity;
            Price    += price;

            DecoratedObj = decoratedObj;
            SetDish(price, quantity, ingredients);
        }
Esempio n. 6
0
 public void Add(IDish dish)
 {
     dbContext.Dishes.Add(new Dish()
     {
         Name = dish.Name
     });
     dbContext.SaveChanges();
 }
Esempio n. 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!");
 }
Esempio n. 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 : )
 }
Esempio n. 9
0
 public PizzaExtraTomatoesDecorator(IDish <EPizzaType> decoratedObj) :
     base(
         decoratedObj,
         Constants.PizzaExtraTomatoesPrice,
         Constants.PizzaExtraTomatoesQuantity,
         new List <string>(Constants.PizzaExtraTomatoesIngredients)
         )
 {
 }
Esempio n. 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;
        }
Esempio n. 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)
         )
 {
 }
Esempio n. 15
0
 public DrinkExtraLemonDecorator(IDish <EDrinkType> decoratedObj) :
     base(
         decoratedObj,
         Constants.DrinkExtraLemonPrice,
         Constants.DrinkExtraLemonQuantity,
         new List <string>(Constants.DrinkExtraLemonIngredients)
         )
 {
 }
Esempio n. 16
0
 public PizzaChickenDecorator(IDish <EPizzaType> decoratedObj) :
     base(
         decoratedObj,
         EPizzaType.CHICKEN,
         Constants.PizzaChickenPrice,
         Constants.PizzaChickenQuantity,
         new List <string>(Constants.PizzaChickenIngredients)
         )
 {
 }
Esempio n. 17
0
 public SaladVegetarianDecorator(IDish <ESaladType> decoratedObj) :
     base(
         decoratedObj,
         ESaladType.VEGETARIAN,
         Constants.SaladVegetarianPrice,
         Constants.SaladVegetarianQuantity,
         new List <string>(Constants.SaladVegetarianIngredients)
         )
 {
 }
Esempio n. 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;
 }
Esempio n. 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)
         )
 {
 }
Esempio n. 22
0
 public DrinkOrangeJuiceDecorator(IDish <EDrinkType> decoratedObj) :
     base(
         decoratedObj,
         EDrinkType.ORANGE_JUICE,
         Constants.DrinkOrangeJuicePrice,
         Constants.DrinkOrangeJuiceQuantity,
         new List <string>(Constants.DrinkOrangeJuiceIngredients)
         )
 {
 }
Esempio n. 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));
        }
Esempio n. 24
0
 public PizzaDiavolaDecorator(IDish <EPizzaType> decoratedObj) :
     base(
         decoratedObj,
         EPizzaType.DIAVOLA,
         Constants.PizzaDiavolaPrice,
         Constants.PizzaDiavolaQuantity,
         new List <string>(Constants.PizzaDiavolaIngredients)
         )
 {
 }
Esempio n. 25
0
 public DrinkColaDecorator(IDish <EDrinkType> decoratedObj) :
     base(
         decoratedObj,
         EDrinkType.COLA,
         Constants.DrinkColaPrice,
         Constants.DrinkColaQuantity,
         new List <string>(Constants.DrinkColaIngredients)
         )
 {
 }
Esempio n. 26
0
 public SaladCaesarDecorator(IDish <ESaladType> decoratedObj) :
     base(
         decoratedObj,
         ESaladType.CAESAR,
         Constants.SaladCaesarPrice,
         Constants.SaladCaesarQuantity,
         new List <string>(Constants.SaladCaesarIngredients)
         )
 {
 }
Esempio n. 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;
 }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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);
 }
Esempio n. 32
0
 public bool IsCorrect(IDish dish, int? pos = null)
 {
     return (dish.TypeId == 4 && dish.TimeofDay == "night");
 }