Beispiel #1
0
 public static IngredientAmountDetailModel MapDetailModel(IngredientAmountEntity entity) =>
 new IngredientAmountDetailModel
 {
     Id                    = entity.Id,
     IngredientId          = entity.Ingredient.Id,
     IngredientName        = entity.Ingredient.Name,
     IngredientDescription = entity.Ingredient.Description
 };
Beispiel #2
0
 public static IngredientAmountDetailModel MapDetailModel(IngredientAmountEntity entity) =>
 new IngredientAmountDetailModel
 {
     Id                    = entity.Id,
     IngredientId          = entity.Ingredient.Id,
     IngredientName        = entity.Ingredient.Name,
     IngredientDescription = entity.Ingredient.Description,
     IngredientImageUrl    = entity.Ingredient.ImageUrl,
     Amount                = entity.Amount,
     Unit                  = (Unit)entity.Unit
 };
Beispiel #3
0
        internal RecipeEntity Map(RecipeDetailModel recipeDetailModel)
        {
            var recipeEntity = new RecipeEntity
            {
                Name        = recipeDetailModel.Name,
                Description = recipeDetailModel.Description,
                Type        = (DAL.Entities.FoodType)recipeDetailModel.Type,
                Duration    = recipeDetailModel.Duration
            };

            if (recipeDetailModel.Id == Guid.Empty)
            {
                recipeDetailModel.Id = recipeEntity.Id;
            }
            else
            {
                recipeEntity.Id = recipeDetailModel.Id;
            }

            foreach (var ingredientModel in recipeDetailModel.Ingredients)
            {
                var ingredientAmount = new IngredientAmountEntity
                {
                    Amount = ingredientModel.Amount,
                    Unit   = (DAL.Entities.Unit)ingredientModel.Unit
                };

                var ingredient = new IngredientEntity
                {
                    Name        = ingredientModel.Name,
                    Description = ingredientModel.Description
                };
                if (ingredientModel.Id == Guid.Empty)
                {
                    ingredientModel.Id = ingredient.Id;
                }
                else
                {
                    ingredient.Id = ingredientModel.Id;
                }

                ingredientAmount.Ingredient = ingredient;
                recipeEntity.Ingredients.Add(ingredientAmount);
            }
            return(recipeEntity);
        }
Beispiel #4
0
 public static IngredientAmountDetailModel MapEntityToDetailModel(IngredientAmountEntity entity) => entity == null
     ? null
     : new()