Ejemplo n.º 1
0
        public async Task <RecipeDto> CreateRecipeAsync(SaveRecipeDto saveRecipeDto, Guid userId)
        {
            var recipe = _mapper.Map <SaveRecipeDto, Recipe>(saveRecipeDto);

            recipe.UserId  = userId;
            recipe.Created = DateTime.Now;
            var timeSpaninMinutes = recipe.PreparationTime.Add(new TimeSpan(0, saveRecipeDto.PreparationTimeInMinutes, 0));

            recipe.PreparationTime = timeSpaninMinutes;
            await _repository.AddAsyn(recipe);

            return(await GetRecipeAsync(recipe.Id));
        }