Esempio n. 1
0
        public CookingRecipeViewModel GetCookingRecipeByIdAsPublic(int cookingRecipeId)
        {
            var recipe = this.cookingRecipeRepo.GetCookingRecipeById(cookingRecipeId);

            var recipeModel = new CookingRecipeViewModel()
            {
                Id = recipe.Id,
                Title = recipe.Title,
                ShortDescription = recipe.ShortDescription,
                ExecutingTime = recipe.ExecutingTime,
                Content = recipe.Content,
                CreationDate = recipe.CreationDate,
                LastModifiedAt = recipe.LastModifiedAt,
                CoverImageFileName = recipe.CoverImageFileName
            };

            if (recipe.Products != null)
            {
                recipeModel.Products = recipe.Products.Split((new[] { ',' }), StringSplitOptions.RemoveEmptyEntries).ToHashSet();
            }

            if (recipe.Hashtags != null)
            {
                recipeModel.Hashtags = recipe.Hashtags.Split((new[] { ',' }), StringSplitOptions.RemoveEmptyEntries).ToHashSet();
            }

            if (recipe.ImagesFileNames != null)
            {
                recipeModel.ImagesFileNames = recipe.ImagesFileNames.Split((new[] { ',' }), StringSplitOptions.RemoveEmptyEntries).ToHashSet();
            }

            return recipeModel;
        }
Esempio n. 2
0
        public List<CookingRecipeViewModel> GetAllRecipesAsPublic()
        {
            var allRecipes = this.GetAllCookingRecipes();
            var publicRecipes = new List<CookingRecipeViewModel>();

            foreach (var recipe in allRecipes)
            {
                var recipeModel = new CookingRecipeViewModel()
                {
                    Id = recipe.Id,
                    Title = recipe.Title,
                    CreationDate = recipe.CreationDate,
                    LastModifiedAt = recipe.LastModifiedAt,
                    CoverImageFileName = recipe.CoverImageFileName,
                    ShortDescription = recipe.ShortDescription
                };

                publicRecipes.Add(recipeModel);
            }

            return publicRecipes;
        }