public void AddHitCount(IHitCountData hitCountData)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                Recipe recipe = null;
                if (hitCountData.RecipeId != 0)
                {
                    recipe = context.Recipes.FirstOrDefault(x => x.Id == hitCountData.RecipeId);
                }
                AspNetUser user = null;
                if (!string.IsNullOrEmpty(hitCountData.UserName))
                {
                    user = context.AspNetUsers.FirstOrDefault(x => x.UserName == hitCountData.UserName);
                }

                HitCount hitCount = new HitCount()
                {
                    HitDate = hitCountData.HitDate,
                    Ip      = hitCountData.Ip,
                    Url     = hitCountData.Url,
                    UserId  = user.Id,
                    Recipe  = recipe
                };
                context.HitCounts.Add(hitCount);
                context.SaveChanges();
            }
        }
        public void EditRecipe(IRecipeData recipe)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                Recipe dbRecipe = context.Recipes.FirstOrDefault(x => x.Id == recipe.Id);
                if (dbRecipe == null)
                {
                    return;
                }

                Measurement measurement = context.Measurements.FirstOrDefault(x => x.Id == recipe.Measurement.Id);

                dbRecipe.Name             = recipe.Name;
                dbRecipe.Description      = recipe.Description;
                dbRecipe.Content          = recipe.Content;
                dbRecipe.IsPublished      = recipe.IsPublished;
                dbRecipe.IsOnlyForFriends = recipe.IsOnlyForFriends;
                dbRecipe.PublishDate      = recipe.PublishDate;
                dbRecipe.Url             = recipe.Url;
                dbRecipe.IngredientCount = recipe.IngredientCount;
                dbRecipe.Measurement     = measurement;
                dbRecipe.PreparationTime = recipe.PreparationTime;
                dbRecipe.WaitingTime     = recipe.WaitingTime;
                dbRecipe.TeaserImageUrl  = recipe.TeaserImageUrl;
                context.SaveChanges();
            }
        }
        public int AddRecipe(IRecipeData recipe)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                Measurement measurement = null;
                if (recipe.Measurement != null && recipe.Measurement.Id != 0)
                {
                    measurement = context.Measurements.FirstOrDefault(x => x.Id == recipe.Measurement.Id);
                }

                Recipe dbRecipe = new Recipe()
                {
                    Name             = recipe.Name,
                    Description      = recipe.Description,
                    Content          = recipe.Content,
                    IsPublished      = recipe.IsPublished,
                    IsOnlyForFriends = recipe.IsOnlyForFriends,
                    PublishDate      = recipe.PublishDate,
                    Url             = recipe.Url,
                    IngredientCount = recipe.IngredientCount,
                    Measurement     = measurement,
                    PreparationTime = recipe.PreparationTime,
                    WaitingTime     = recipe.WaitingTime
                };
                context.Recipes.Add(dbRecipe);
                context.SaveChanges();

                recipe.Id = dbRecipe.Id;
                return(recipe.Id);
            }
        }
        public List <IRecipeContent> LoadRecipeContents(int recipeId)
        {
            List <IRecipeContent> contents = new List <IRecipeContent>();

            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                try
                {
                    var recipeContents = context.RecipeContents.Where(x => x.RecipeId == recipeId).ToList();
                    if (recipeContents == null)
                    {
                        return(contents);
                    }

                    foreach (var recipeContent in recipeContents)
                    {
                        contents.Add(new LudwigRecipe.Data.DataModels.Recipe.RecipeContent()
                        {
                            Id = recipeContent.Id,
                            RecipeContentTypeId = recipeContent.RecipeContentType.Id,
                            Content             = recipeContent.Content,
                            SortOrder           = recipeContent.SortOrder
                        });
                    }
                }
                catch (Exception e)
                {
                }
            }
            return(contents);
        }
        public List <ICategoryData> LoadCategories()
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                List <ICategoryData> categories   = new List <ICategoryData>();
                List <Category>      dbCategories = context.Categories.ToList();
                foreach (Category category in dbCategories)
                {
                    List <ISubCategoryData> subCategories = new List <ISubCategoryData>();

                    foreach (SubCategory subCategory in category.SubCategories)
                    {
                        subCategories.Add(new SubCategoryData()
                        {
                            CategoryId = category.Id,
                            Id         = subCategory.Id,
                            Name       = subCategory.Name,
                            Order      = subCategory.DisplayOrder,
                            Url        = subCategory.Url
                        });
                    }

                    categories.Add(new CategoryData()
                    {
                        Id            = category.Id,
                        IsMainMenu    = category.IsDisplayInMainNavigation,
                        Name          = category.Name,
                        Order         = category.DisplayOrder,
                        Url           = category.Url,
                        SubCategories = subCategories
                    });
                }
                return(categories);
            }
        }
 public void DeleteRecipe(int id)
 {
     using (LudwigRecipeContext context = new LudwigRecipeContext())
     {
         context.Recipes.Remove(context.Recipes.FirstOrDefault(x => x.Id == id));
         context.SaveChanges();
     }
 }
 public void DeleteAllRecipeContents(int recipeId)
 {
     using (LudwigRecipeContext context = new LudwigRecipeContext())
     {
         context.RecipeContents.RemoveRange(context.RecipeContents.Where(x => x.RecipeId == recipeId));
         context.SaveChanges();
     }
 }
        public void DeleteSubCategoriesWhereNotInLIst(List <int> subCategoryIDs)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                List <SubCategory> subCategories = context.SubCategories.Where(x => !subCategoryIDs.Contains(x.Id)).ToList();

                context.SubCategories.RemoveRange(subCategories);
                context.SaveChanges();
            }
        }
        public void DeleteIngredientListFromRecipeWhereNotInList(List <int> ingerdientListIds, int recipeId)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                List <IngredientList> ingredientLists = context.IngredientLists.Where(x => !ingerdientListIds.Contains(x.Id) && x.Recipe.Id == recipeId).ToList();

                context.IngredientLists.RemoveRange(ingredientLists);
                context.SaveChanges();
            }
        }
 public string LoadSubCategoryNameByUrl(string url)
 {
     using (LudwigRecipeContext context = new LudwigRecipeContext())
     {
         SubCategory subCategory = context.SubCategories.FirstOrDefault(x => x.Url == url);
         if (subCategory == null)
         {
             return(string.Empty);
         }
         return(subCategory.Name);
     }
 }
        public void SaveSubCategory(ISubCategoryData subCategory)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                SubCategory changeSubCategory = context.SubCategories.FirstOrDefault(x => x.Id == subCategory.Id);

                changeSubCategory.DisplayOrder = subCategory.Order;
                changeSubCategory.Name         = subCategory.Name;
                changeSubCategory.Url          = subCategory.Url;

                context.SaveChanges();
            }
        }
        public int LoadOverviewRecipesCount(IRequestRecipe requestData)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                List <IRecipeOverviewData> data = new List <IRecipeOverviewData>();

                var recipeQuery = context.Recipes.AsQueryable();

                int categoryId = 0;
                if (!String.IsNullOrEmpty(requestData.CategoryUrl))
                {
                    Category category = context.Categories.FirstOrDefault(x => x.Url == requestData.CategoryUrl);
                    if (category != null)
                    {
                        categoryId  = category.Id;
                        recipeQuery = recipeQuery.Where(x => x.Categories.FirstOrDefault(y => y.Id == category.Id) != null);
                    }
                }

                int subCategoryId = 0;
                if (!String.IsNullOrEmpty(requestData.SubCategoryUrl))
                {
                    SubCategory subCategory = context.SubCategories.FirstOrDefault(x => x.Url == requestData.SubCategoryUrl);
                    if (subCategory != null)
                    {
                        recipeQuery = recipeQuery.Where(x => x.SubCategories.FirstOrDefault(y => y.Id == subCategory.Id && y.CategoryId == categoryId) != null);
                    }
                }

                if (requestData.ForPublicWeb)
                {
                    recipeQuery = recipeQuery.Where(x => x.IsPublished == true && x.PublishDate <= DateTime.Now);
                }

                if (!requestData.IsFriend)
                {
                    recipeQuery = recipeQuery.Where(x => x.IsOnlyForFriends == false);
                }

                try
                {
                    var recipes = recipeQuery.ToList();
                    return(recipes.Count());
                }
                catch (Exception exception)
                {
                }

                return(0);
            }
        }
        public void SaveCategory(ICategoryData category)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                Category changeCategory = context.Categories.FirstOrDefault(x => x.Id == category.Id);

                changeCategory.DisplayOrder = category.Order;
                changeCategory.IsDisplayInMainNavigation = category.IsMainMenu;
                changeCategory.Name = category.Name;
                changeCategory.Url  = category.Url;

                context.SaveChanges();
            }
        }
 public void AddRecipeContent(int recipeId, IRecipeContent content)
 {
     using (LudwigRecipeContext context = new LudwigRecipeContext())
     {
         context.RecipeContents.Add(new LudwigRecipe.Data.DataContext.RecipeContent()
         {
             RecipeId      = recipeId,
             Content       = content.Content,
             ContentTypeId = content.RecipeContentTypeId,
             SortOrder     = content.SortOrder
         });
         context.SaveChanges();
     }
 }
        public void EditTeaserImage(int recipeId, string teaserImageUrl)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                Recipe dbRecipe = context.Recipes.FirstOrDefault(x => x.Id == recipeId);
                if (dbRecipe == null)
                {
                    return;
                }

                dbRecipe.TeaserImageUrl = teaserImageUrl;

                context.SaveChanges();
            }
        }
 public int AddCategory(ICategoryData category)
 {
     using (LudwigRecipeContext context = new LudwigRecipeContext())
     {
         Category newCategory = new Category()
         {
             DisplayOrder = category.Order,
             IsDisplayInMainNavigation = category.IsMainMenu,
             Name = category.Name,
             Url  = category.Url
         };
         context.Categories.Add(newCategory);
         context.SaveChanges();
         return(newCategory.Id);
     }
 }
        public IRecipeDetailData LoadRecipeDetail(int id, bool forPublicWeb, bool isFriend)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                IRecipeDetailData recipe = null;

                var dbRecipeQuery = context.Recipes.AsQueryable();

                dbRecipeQuery = dbRecipeQuery.Where(x => x.Id == id);

                if (forPublicWeb)
                {
                    dbRecipeQuery = dbRecipeQuery.Where(x => x.IsPublished == true && x.PublishDate <= DateTime.Now);
                }
                if (!isFriend)
                {
                    dbRecipeQuery = dbRecipeQuery.Where(x => x.IsOnlyForFriends == false);
                }

                var dbRecipe = dbRecipeQuery.FirstOrDefault();

                if (dbRecipe != null)
                {
                    recipe = new RecipeDetailData()
                    {
                        Id              = dbRecipe.Id,
                        Name            = dbRecipe.Name,
                        Description     = dbRecipe.Description,
                        Content         = dbRecipe.Content,
                        PublishDate     = dbRecipe.PublishDate,
                        Url             = dbRecipe.Url,
                        TeaserImageUrl  = dbRecipe.TeaserImageUrl,
                        IngredientCount = dbRecipe.IngredientCount,
                        Measurement     = (dbRecipe.Measurement != null) ? new MeasurementData()
                        {
                            Id = dbRecipe.Measurement.Id, Name = dbRecipe.Measurement.Name
                        } : null,
                        PreparationTime = dbRecipe.PreparationTime,
                        WaitingTime     = dbRecipe.WaitingTime
                    };
                }

                return(recipe);
            }
        }
示例#18
0
        public int FindOrAddMeasurement(string measurement)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                Measurement dbMeasurement = context.Measurements.FirstOrDefault(x => x.Name.ToLower() == measurement.ToLower().Trim());

                if (dbMeasurement == null)
                {
                    dbMeasurement = new Measurement()
                    {
                        Name = measurement
                    };
                    context.Measurements.Add(dbMeasurement);
                    context.SaveChanges();
                }
                return(dbMeasurement.Id);
            }
        }
        public List <IIngredientData> LoadIngredients()
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                List <IIngredientData> ingredients = new List <IIngredientData>();

                List <Ingredient> dbIngredients = context.Ingredients.OrderBy(x => x.Name).ToList();
                foreach (Ingredient dbIngredient in dbIngredients)
                {
                    ingredients.Add(new IngredientData()
                    {
                        Id   = dbIngredient.Id,
                        Name = dbIngredient.Name
                    });
                }
                return(ingredients);
            }
        }
        public int AddSubCategory(ISubCategoryData subCategory)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                Category category = context.Categories.FirstOrDefault(x => x.Id == subCategory.CategoryId);

                SubCategory newSubCategory = new SubCategory()
                {
                    DisplayOrder = subCategory.Order,
                    Name         = subCategory.Name,
                    Url          = subCategory.Url,
                    Category     = category
                };
                context.SubCategories.Add(newSubCategory);
                context.SaveChanges();
                return(newSubCategory.Id);
            }
        }
示例#21
0
        public List <IMeasurementData> LoadMeasurements()
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                List <IMeasurementData> measurements = new List <IMeasurementData>();

                List <Measurement> dbMeasurements = context.Measurements.OrderBy(x => x.Name).ToList();
                foreach (Measurement dbMeasurement in dbMeasurements)
                {
                    measurements.Add(new MeasurementData()
                    {
                        Id   = dbMeasurement.Id,
                        Name = dbMeasurement.Name
                    });
                }
                return(measurements);
            }
        }
        public IRecipeData LoadRecipe(int id)
        {
            IRecipeData recipe = null;

            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                try
                {
                    var dbRecipeQuery = context.Recipes.AsQueryable();

                    dbRecipeQuery = dbRecipeQuery.Where(x => x.Id == id);

                    var dbRecipe = dbRecipeQuery.FirstOrDefault();

                    if (dbRecipe != null)
                    {
                        recipe = new RecipeData()
                        {
                            Id               = dbRecipe.Id,
                            IsPublished      = dbRecipe.IsPublished,
                            IsOnlyForFriends = dbRecipe.IsOnlyForFriends,
                            Name             = dbRecipe.Name,
                            Description      = dbRecipe.Description,
                            Content          = dbRecipe.Content,
                            PublishDate      = dbRecipe.PublishDate,
                            Url              = dbRecipe.Url,
                            TeaserImageUrl   = dbRecipe.TeaserImageUrl,
                            IngredientCount  = dbRecipe.IngredientCount,
                            Measurement      = (dbRecipe.Measurement != null) ? new MeasurementData()
                            {
                                Id = dbRecipe.Measurement.Id, Name = dbRecipe.Measurement.Name
                            } : new MeasurementData(),
                            PreparationTime = dbRecipe.PreparationTime,
                            WaitingTime     = dbRecipe.WaitingTime
                        };
                    }
                }
                catch (Exception e)
                {
                }
            }
            return(recipe);
        }
        public List <ISeoTagData> LoadSeoTags()
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                List <ISeoTagData> seoTags = new List <ISeoTagData>();

                List <SeoTag> dbSeoTags = context.SeoTags.ToList();

                foreach (SeoTag dbSeoTag in dbSeoTags)
                {
                    seoTags.Add(new SeoTagData()
                    {
                        Id   = dbSeoTag.Id,
                        Name = dbSeoTag.Name
                    });
                }

                return(seoTags);
            }
        }
        public void AddAndRemoveSubCategoriesFromRecipe(List <int> subCategoryIds, int recipeId)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                Recipe recipe = context.Recipes.FirstOrDefault(x => x.Id == recipeId);
                if (recipe == null)
                {
                    return;
                }

                recipe.SubCategories.Clear();
                context.SaveChanges();

                List <SubCategory> subCategories = context.SubCategories.Where(x => subCategoryIds.Contains(x.Id)).ToList();
                foreach (SubCategory subCategory in subCategories)
                {
                    recipe.SubCategories.Add(subCategory);
                }
                context.SaveChanges();
            }
        }
        public List <ICategorySelectData> LoadCategoriesForRecipe(int recipeId)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                Recipe recipe = context.Recipes.FirstOrDefault(x => x.Id == recipeId);
                if (recipe == null)
                {
                    return(null);
                }

                List <int> selectedCategories    = recipe.Categories.Select(x => x.Id).ToList <int>();
                List <int> selectedSubCategories = recipe.SubCategories.Select(x => x.Id).ToList <int>();

                List <ICategorySelectData> categories   = new List <ICategorySelectData>();
                List <Category>            dbCategories = context.Categories.ToList();
                foreach (Category category in dbCategories)
                {
                    List <ISubCategorySelectData> subCategories = new List <ISubCategorySelectData>();

                    foreach (SubCategory subCategory in category.SubCategories)
                    {
                        subCategories.Add(new SubCategorySelectData()
                        {
                            Id         = subCategory.Id,
                            Name       = subCategory.Name,
                            IsSelected = selectedSubCategories.Contains(subCategory.Id)
                        });
                    }

                    categories.Add(new CategorySelectData()
                    {
                        Id               = category.Id,
                        Name             = category.Name,
                        IsSelected       = selectedCategories.Contains(category.Id),
                        SubCategoryDatas = subCategories
                    });
                }
                return(categories);
            }
        }
        public int AddOrSelectSeoTag(ISeoTagData seoTagData)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                seoTagData.Name = seoTagData.Name.Trim();
                if (string.IsNullOrEmpty(seoTagData.Name))
                {
                    return(0);
                }

                SeoTag seoTag = context.SeoTags.FirstOrDefault(x => x.Name.ToLower() == seoTagData.Name.ToLower());
                if (seoTag == null)
                {
                    seoTag = new SeoTag()
                    {
                        Name = seoTagData.Name
                    };
                    context.SeoTags.Add(seoTag);
                    context.SaveChanges();
                }
                return(seoTag.Id);
            }
        }
        public int FindOrAddIngredient(string ingredient)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                if (string.IsNullOrWhiteSpace(ingredient))
                {
                    return(0);
                }

                Ingredient dbIngredient = context.Ingredients.FirstOrDefault(x => x.Name.ToLower() == ingredient.ToLower().Trim());

                if (dbIngredient == null)
                {
                    dbIngredient = new Ingredient()
                    {
                        Name = ingredient
                    };
                    context.Ingredients.Add(dbIngredient);
                    context.SaveChanges();
                }
                return(dbIngredient.Id);
            }
        }
        public List <IIngredientListData> LoadIngredientListFromRecipe(int recipeId)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                List <IIngredientListData> ingredientLists   = new List <IIngredientListData>();
                List <IngredientList>      dbIngredientLists = context.IngredientLists.Where(x => x.Recipe.Id == recipeId).OrderBy(y => y.SortOrder).ToList();

                foreach (IngredientList dbIngredientList in dbIngredientLists)
                {
                    ingredientLists.Add(new IngredientListData()
                    {
                        Id              = dbIngredientList.Id,
                        Amount          = dbIngredientList.Amount,
                        IngredientId    = dbIngredientList.Ingredient.Id,
                        IngredientName  = dbIngredientList.Ingredient.Name,
                        MeasurementId   = dbIngredientList.Measurement.Id,
                        MeasurementName = dbIngredientList.Measurement.Name,
                        SortOrder       = dbIngredientList.SortOrder,
                        RecipeId        = recipeId
                    });
                }
                return(ingredientLists);
            }
        }
        public List <ICategoryData> LoadCategoriesWithRecipes(bool isFriend)
        {
            List <ICategoryData> categories = new List <ICategoryData>();

            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                List <int> categoryIds    = new List <int>();
                List <int> subCategoryIds = new List <int>();

                List <IEnumerable <int> > categoriesFromRecipeIds = context.Recipes.Where(x => x.IsPublished && x.PublishDate <= DateTime.Now).Select(x => x.Categories.Select(y => y.Id)).ToList();
                foreach (List <int> categoriesFromRecipeId in categoriesFromRecipeIds)
                {
                    foreach (int categorieId in categoriesFromRecipeId)
                    {
                        if (!categoryIds.Contains(categorieId))
                        {
                            categoryIds.Add(categorieId);
                        }
                    }
                }

                List <IEnumerable <int> > subCategoriesFromRecipeIds = context.Recipes.Where(x => x.IsPublished && x.PublishDate <= DateTime.Now).Select(x => x.SubCategories.Select(y => y.Id)).ToList();
                foreach (List <int> subCategoriesFromRecipeId in subCategoriesFromRecipeIds)
                {
                    foreach (int subCategorieId in subCategoriesFromRecipeId)
                    {
                        if (!subCategoryIds.Contains(subCategorieId))
                        {
                            subCategoryIds.Add(subCategorieId);
                        }
                    }
                }

                foreach (int categoryId in categoryIds)
                {
                    List <ISubCategoryData> subCategories = new List <ISubCategoryData>();

                    Category           dbCategory      = context.Categories.FirstOrDefault(x => x.Id == categoryId);
                    List <SubCategory> dbSubCategories = context.SubCategories.Where(x => x.CategoryId == categoryId && subCategoryIds.Contains(x.Id)).ToList();

                    if (dbSubCategories != null)
                    {
                        foreach (SubCategory subCategory in dbSubCategories)
                        {
                            if (subCategories.FirstOrDefault(x => x.Id == subCategory.Id) != null)
                            {
                                continue;
                            }
                            subCategories.Add(new SubCategoryData()
                            {
                                CategoryId = categoryId,
                                Id         = subCategory.Id,
                                Name       = subCategory.Name,
                                Order      = subCategory.DisplayOrder,
                                Url        = subCategory.Url
                            });
                        }
                    }
                    categories.Add(new CategoryData()
                    {
                        Id            = dbCategory.Id,
                        IsMainMenu    = dbCategory.IsDisplayInMainNavigation,
                        Name          = dbCategory.Name,
                        Order         = dbCategory.DisplayOrder,
                        Url           = dbCategory.Url,
                        SubCategories = subCategories
                    });
                }
            }
            return(categories);
        }
        public List <IRecipeOverviewData> LoadOverviewRecipes(IRequestRecipe requestData)
        {
            using (LudwigRecipeContext context = new LudwigRecipeContext())
            {
                List <IRecipeOverviewData> data = new List <IRecipeOverviewData>();

                var recipeQuery = context.Recipes.AsQueryable();

                if (!String.IsNullOrEmpty(requestData.SearchTerm))
                {
                    recipeQuery = recipeQuery.Where(x => x.Name.Contains(requestData.SearchTerm));
                }

                if (!String.IsNullOrEmpty(requestData.CategoryUrl))
                {
                    Category category = context.Categories.FirstOrDefault(x => x.Url == requestData.CategoryUrl);
                    if (category != null)
                    {
                        recipeQuery = recipeQuery.Where(x => x.Categories.FirstOrDefault(y => y.Id == category.Id) != null);
                    }
                }

                if (!String.IsNullOrEmpty(requestData.SubCategoryUrl))
                {
                    SubCategory subCategory = context.SubCategories.FirstOrDefault(x => x.Url == requestData.SubCategoryUrl);
                    if (subCategory != null)
                    {
                        recipeQuery = recipeQuery.Where(x => x.SubCategories.FirstOrDefault(y => y.Id == subCategory.Id) != null);
                    }
                }


                if (requestData.ForPublicWeb)
                {
                    recipeQuery = recipeQuery.Where(x => x.IsPublished == true && x.PublishDate <= DateTime.Now);
                }

                if (!requestData.IsFriend)
                {
                    recipeQuery = recipeQuery.Where(x => x.IsOnlyForFriends == false);
                }

                recipeQuery = recipeQuery.OrderByDescending(x => x.PublishDate);

                if (requestData.Skip > 0)
                {
                    recipeQuery = recipeQuery.Skip(requestData.Skip);
                }
                if (requestData.Top > 0)
                {
                    recipeQuery = recipeQuery.Take(requestData.Top);
                }
                try
                {
                    var recipes = recipeQuery.ToList();

                    foreach (var recipe in recipes)
                    {
                        data.Add(new RecipeOverviewData()
                        {
                            Id             = recipe.Id,
                            Name           = recipe.Name,
                            Url            = recipe.Url,
                            Description    = recipe.Description,
                            PublishDate    = recipe.PublishDate,
                            TeaserImageUrl = recipe.TeaserImageUrl
                        });
                    }
                }
                catch (Exception exception)
                {
                }

                return(data);
            }
        }