Beispiel #1
0
        public GlobalQuery(IngredientRepository ingredientRepository, StepRepository stepRepository, RecipeRepository recipeRepository)
        {
            Field <ListGraphType <IngredientType> >("ingredients",
                                                    resolve: context => ingredientRepository.GetAll());
            Field <ListGraphType <StepType> >("steps",
                                              resolve: context => stepRepository.GetAll());
            Field <ListGraphType <RecipeType> >("recipes",
                                                resolve: context => recipeRepository.GetAll());

            Field <RecipeType>(
                nameof(Recipe),
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = nameof(Recipe.RecipeId)
            }),
                resolve: (context) =>
            {
                var recipeId = context.GetArgument <long>("recipeId");
                return(recipeRepository.GetRecipeById(recipeId));
            });
        }
Beispiel #2
0
        public void GetAll_Test()
        {
            // Arrange - Create the repository
            var repository = new RecipeRepository(_context);

            // Act - Set-up the repository call
            repository.FullEagerLoad();
            var actualList = repository.GetAll();

            // Assert - Check the result
            Assert.IsNotNull(actualList);
            Assert.IsTrue(actualList.Count() > 0);

            // Assert - Check the list count against the sample data.
            var sampleData = new SampleContext();

            Assert.AreEqual(actualList.Count(), sampleData.Recipes.Entities.Count());

            // Assert - Test the first recipe
            var recipe = actualList.First();

            VerifyEntity(recipe);
        }
        /// <summary>
        /// Method to get a list of all recipes
        /// </summary>
        /// <returns>A List of all Recipes</returns>
        public async Task <List <RecipeDTO> > GetAllRecipesAsync()
        {
            var recipeList = new List <RecipeDTO>();

            try
            {
                var allrecipes = await Task.Run(() => recipeRepository.GetAll());

                //get a list of all recipes and return them
                recipeList = (from recipes in allrecipes
                              select new RecipeDTO
                {
                    RecipeId = recipes.RecipeId,
                    Name = recipes.Name
                }).ToList <RecipeDTO>();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return(recipeList);
        }
 public IActionResult Get()
 {
     return(Ok(_recipeRepository.GetAll()));
 }
Beispiel #5
0
 public IEnumerable <Recipe> GetAll()
 {
     return(recipeRepository.GetAll());
 }
Beispiel #6
0
 public List <Recipe> GetAll()
 {
     return(_repo.GetAll());
 }
Beispiel #7
0
        public List <RecipeListModel> GetAll()
        {
            var recipeEntities = recipeRepository.GetAll();

            return(mapper.Map <List <RecipeListModel> >(recipeEntities));
        }
        public List <UserModelView> AllUsersByAdmin()
        {
            ReportRepository     reportRepo = new ReportRepository();
            RecipeRepository     recipeRepo = new RecipeRepository();
            PostRepository       postRepo   = new PostRepository();
            RestaurantRepository restRepo   = new RestaurantRepository();



            List <UserModelView> userModelList = new List <UserModelView>();



            foreach (var user in this.GetAll())
            {
                UserModelView umv = new UserModelView();

                umv.TotalReport     = 0;
                umv.TotalRecipe     = 0;
                umv.TotalPost       = 0;
                umv.TotalRestaurant = 0;

                umv.Name   = user.Name;
                umv.Image  = user.Image;
                umv.UserId = user.UserID;

                //toral report
                foreach (var report in reportRepo.GetAllReports())
                {
                    if (user.UserID == report.ReportedId)
                    {
                        umv.TotalReport += 1;
                    }
                }

                //toral recipe
                foreach (var recipe in recipeRepo.GetAll())
                {
                    if (user.UserID == recipe.UserId)
                    {
                        umv.TotalRecipe += 1;
                    }
                }


                //toral post
                foreach (var post in postRepo.GetAll())
                {
                    if (user.UserID == post.UserID)
                    {
                        umv.TotalPost += 1;
                    }
                }



                //Total Restaurant

                foreach (var rest in restRepo.GetAll())
                {
                    if (user.UserID == rest.UserID)
                    {
                        umv.TotalRestaurant += 1;
                    }
                }

                userModelList.Add(umv);
            }



            return(userModelList);
        }
Beispiel #9
0
        // GET: Recipe
        public ActionResult Index()
        {
            RecipeViewModel model = new RecipeViewModel(repo.GetAll());

            return(View(model));
        }
        public void GetAllTest()
        {
            var recipes = _recipeRepository.GetAll();

            Assert.IsEmpty(recipes);
        }
Beispiel #11
0
 public async Task <List <Recipe> > GetAllAsync()
 {
     return(await _recipeRepository.GetAll());
 }