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(); }
public async Task Modify(string id, ModifyDishDto request) { Guid.TryParse(id, out Guid dishId); // var dish = await _dishes.Get(dishId); // if(request.Name != ) }
public async Task <IActionResult> ReplaceDish(string id, ModifyDishDto request) { await _menuService.Replace(id, request); return(NoContent()); }
public IActionResult UpdateDish(string id, ModifyDishDto request) { return(Ok()); }