public async Task <IActionResult> RemoveIngredientAsync(Guid ingredientListId, Guid ingredientId) { IActionResult actionResult; try { var ingredientList = await _ingredientListRepository.GetAsync(ingredientListId); ingredientList.RemoveIngredientFromList(ingredientId); await _ingredientListRepository.StoreAsync(ingredientList); actionResult = Ok(); } catch (Exception exception) when(ExceptionToStatusCode.CanConvert(exception, out actionResult)) { } return(actionResult); }
public async Task <IActionResult> AddIngredientAsync(Guid ingredientListId, [FromBody] IngredientCreateDto ingredientCreateDto) { IActionResult actionResult; try { var ingredient = IngredientCreateDto.ToIngredient(ingredientCreateDto); var ingredientList = await _ingredientListRepository.GetAsync(ingredientListId); ingredientList.AddIngredientToList(ingredient); actionResult = Ok(); } catch (Exception exception) when(ExceptionToStatusCode.CanConvert(exception, out actionResult)) { } return(actionResult); }