Exemplo n.º 1
0
        public async Task <CocktailResponse> AddAsync(Domain.Models.Cocktail cocktail, List <Ingredient> ingredients)
        {
            try
            {
                await _cocktailRepository.AddAsync(cocktail, ingredients);

                await _unitOfWork.CompleteAsync();

                return(new CocktailResponse(cocktail));
            }
            catch (Exception ex)
            {
                return(new CocktailResponse($"An error occurred when saving the cocktail: {ex.Message}"));
            }
        }
Exemplo n.º 2
0
        public async Task <CocktailResponse> AddAsync(Cocktail cocktail, List <Ingredients> ingredients)
        {
            try
            {
                await _cocktailRepository.AddAsync(cocktail, ingredients);

                await _unitOfWork.CompleteAsync();

                return(new CocktailResponse(cocktail));
            }
            catch (Exception ex)
            {
                // Do some logging stuff
                return(new CocktailResponse($"An error occurred when saving the category: {ex.Message}"));
            }
        }