internal IEnumerable <Recipe> GetRecipes(RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages) { using (MyBuyListDBContext context = new MyBuyListDBContext(DBUtils.GetConnection())) { try { DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith <Recipe>(r => r.User); DataContext.LoadOptions = dlo; var count = (from r in DataContext.Recipes select r).Count(); totalPages = count / pageSize + (count % pageSize > 0 ? 1 : 0); var list = from r in DataContext.Recipes select r; switch (orderBy) { case RecipeOrderEnum.Name: list = list.OrderBy(r => r.RecipeName); break; case RecipeOrderEnum.Publisher: list = list.OrderBy(r => r.User.DisplayName); break; case RecipeOrderEnum.LastUpdate: list = list.OrderByDescending(r => r.ModifiedDate); break; } // paging var list2 = list.Skip((page - 1) * pageSize).Take(pageSize); return(list2.ToList()); } catch { totalPages = 0; return(null); } } }
internal IEnumerable <Recipe> GetRecipes(RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages) { using (DataContext) { try { var count = (from r in DataContext.Recipes select r).Count(); totalPages = count / pageSize + (count % pageSize > 0 ? 1 : 0); var list = from r in DataContext.Recipes select r; switch (orderBy) { case RecipeOrderEnum.Name: list = list.OrderBy(r => r.RecipeName); break; case RecipeOrderEnum.Publisher: list = list.OrderBy(r => r.User.DisplayName); break; case RecipeOrderEnum.LastUpdate: list = list.OrderByDescending(r => r.ModifiedDate); break; } // paging var list2 = list.Skip((page - 1) * pageSize).Take(pageSize); return(list2.ToList()); } catch { totalPages = 0; return(null); } } }
public IEnumerable <Menu> GetMenusEx(RecipeDisplayEnum display, int userId, string freeText, int?categoryId, int?diners, int[] menuCats, RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages, out int numMenus) { return(new MenusDA().GetMenusEx(display, userId, freeText, categoryId, diners, menuCats, orderBy, page, pageSize, out totalPages, out numMenus)); }
public IEnumerable <Menu> GetMenus(int userid, RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages) { return(new MenusDA().GetMenus(userid, orderBy, page, pageSize, out totalPages)); }
public IEnumerable <Recipe> GetRecipesEx(RecipeDisplayEnum display, int userId, string freeText, int?categoryId, int?servings, int[] recipeCats, RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages, out int numRecipes) { return(new RecipesDA().GetRecipesEx(display, userId, freeText, categoryId, servings, recipeCats, orderBy, page, pageSize, out totalPages, out numRecipes)); }
public IEnumerable <Recipe> GetRecipes(RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages) { return(new RecipesDA().GetRecipes(orderBy, page, pageSize, out totalPages)); }
internal List <Recipe> GetRecipesEx(RecipeDisplayEnum display, int userId, string freeText, int?categoryId, int?servings, int[] recipeCats, RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages, out int numRecipes) { using (MyBuyListDBContext context = new MyBuyListDBContext(DBUtils.GetConnection())) { try { List <Recipe> recipesList = null; switch (display) { case RecipeDisplayEnum.All: recipesList = GetAllRecipes(userId).ToList(); break; case RecipeDisplayEnum.MyRecipes: if (!string.IsNullOrEmpty(freeText)) { recipesList = GetUserRecipesList(userId).Where(r => r.RecipeName.Contains(freeText)).ToList(); } else { recipesList = GetUserRecipesList(userId).ToList(); } break; case RecipeDisplayEnum.MyFavoriteRecipes: if (!string.IsNullOrEmpty(freeText)) { recipesList = GetUserFavoritesRecipes(userId).Where(r => r.RecipeName.Contains(freeText)).ToList(); } else { recipesList = GetUserFavoritesRecipes(userId).ToList(); } break; case RecipeDisplayEnum.ByCategory: if (categoryId.HasValue) { recipesList = this.GetRecipesByCategory(categoryId.Value, userId).ToList(); } else { recipesList = this.GetAllRecipes(userId).ToList(); } break; case RecipeDisplayEnum.BySearchSimple: recipesList = GetRecipesListByFreeText(freeText).ToList(); break; case RecipeDisplayEnum.BySearchAdvanced: recipesList = this.GetRecipesListByComplexSearch(freeText, servings, recipeCats, userId).ToList(); break; } var count = (from r in recipesList select r).Count(); numRecipes = count; totalPages = count / pageSize + (count % pageSize > 0 ? 1 : 0); var list = from r in recipesList select r; switch (orderBy) { case RecipeOrderEnum.Name: list = list.OrderBy(r => r.RecipeName); break; case RecipeOrderEnum.Publisher: list = list.OrderBy(r => r.User.DisplayName); break; case RecipeOrderEnum.LastUpdate: list = list.OrderByDescending(r => r.ModifiedDate); break; } // paging var list2 = list.Skip((page - 1) * pageSize).Take(pageSize); return(list2.ToList()); } catch { totalPages = 0; numRecipes = 0; return(null); } } }
internal IEnumerable <Menu> GetMenusEx(RecipeDisplayEnum display, int userId, string freeText, int?categoryId, int?diners, int[] menuCats, RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages, out int numMenus) { return(DataFacade.Instance.GetMenusEx(display, userId, freeText, categoryId, diners, menuCats, orderBy, page, pageSize, out totalPages, out numMenus)); }
internal IEnumerable <Menu> GetMenus(int userid, RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages) { return(DataFacade.Instance.GetMenus(userid, orderBy, page, pageSize, out totalPages)); }
internal IEnumerable <Recipe> GetRecipesEx(RecipeDisplayEnum display, int userId, string freeText, int?categoryId, int?servings, int[] recipeCats, RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages, out int numRecipes) { return(DataFacade.Instance.GetRecipesEx(display, userId, freeText, categoryId, servings, recipeCats, orderBy, page, pageSize, out totalPages, out numRecipes)); }
internal IEnumerable <Recipe> GetRecipes(RecipeOrderEnum orderBy, int page, int pageSize, out int totalPages) { return(DataFacade.Instance.GetRecipes(orderBy, page, pageSize, out totalPages)); }