Example #1
0
        public async Task Replace(string id, ModifyDishDto request)
        {
            Guid.TryParse(id, out Guid dishId);
            var dish = await _unityOfWork.DishesRepository.Get(dishId);

            dish.Name  = request.Name;
            dish.Price = request.Price;
            dish.DishIngredients.Clear();


            foreach (var requestDishIngredient in request.DishIngredients)
            {
                var ingredient = await _unityOfWork.IngredientsRepository.Get(requestDishIngredient.Key);

                var link = new DishIngredient()
                {
                    Dish       = dish,
                    Ingredient = ingredient,
                    Quantity   = requestDishIngredient.Value
                };

                await _unityOfWork.DishIngredientsRepository.Add(link);
            }

            await _unityOfWork.DishesRepository.Update(dish);

            await _unityOfWork.CommitAsync();
        }
Example #2
0
        public async Task Modify(string id, ModifyDishDto request)
        {
            Guid.TryParse(id, out Guid dishId);

            // var dish = await _dishes.Get(dishId);
            // if(request.Name != )
        }
Example #3
0
        public async Task <IActionResult> ReplaceDish(string id, ModifyDishDto request)
        {
            await _menuService.Replace(id, request);

            return(NoContent());
        }
Example #4
0
 public IActionResult UpdateDish(string id, ModifyDishDto request)
 {
     return(Ok());
 }