Пример #1
0
        public static RecipeIngredient ToEntity(this RecipeIngredientDTO recipeIngredientDTO)
        {
            if (recipeIngredientDTO == null)
            {
                return(null);
            }

            RecipeIngredient recipeIngredient = new RecipeIngredient
            {
                RecipeId     = recipeIngredientDTO.RecipeId,
                IngredientId = recipeIngredientDTO.IngredientId,
                Amount       = recipeIngredientDTO.Amount,
                Unit         = recipeIngredientDTO.Unit
            };

            return(recipeIngredient);
        }
Пример #2
0
        public static RecipeIngredientDTO ToDto(this RecipeIngredient recipeIngredient)
        {
            if (recipeIngredient == null)
            {
                return(null);
            }

            RecipeIngredientDTO recipeIngredientDTO = new RecipeIngredientDTO
            {
                RecipeId       = recipeIngredient.RecipeId,
                RecipeName     = recipeIngredient.Recipe.Name,
                IngredientId   = recipeIngredient.IngredientId,
                IngredientName = recipeIngredient.Ingredient.Name,
                Amount         = recipeIngredient.Amount,
                Unit           = recipeIngredient.Unit
            };

            return(recipeIngredientDTO);
        }