Exemple #1
0
        public async Task <List <IngredientsUsageViewModel> > IngredientsUsage()
        {
            var ingredientsUsageList = new List <IngredientsUsageViewModel>();
            var ingredients          = await _ingredientsRepository.GetIngredients();

            //"CreateNewIngredient" - model for get amount as property
            foreach (var item in ingredients)
            {
                var findIngredientsIntoDishes = await _dishesIngredientsRepository.UsageOfIngredients(item.Id);

                var listOfIngredients = new List <IngredientsView>();
                var listOfAmounts     = new List <CreateNewIngredient>();
                foreach (var item2 in findIngredientsIntoDishes)
                {
                    var ingredient = new IngredientsView();
                    ingredient.Id = item2.Id;
                    listOfIngredients.Add(ingredient);

                    var ingredientPerDish = new CreateNewIngredient();
                    ingredientPerDish.Amount = item2.Amount;
                    listOfAmounts.Add(ingredientPerDish);
                }
                int numberOfIngredientsInDishes = listOfIngredients.Count();
                var amoutOfIngredientsInDishes  = listOfAmounts.Sum(x => x.Amount);
                var ingredientsUsage            = new IngredientsUsageViewModel()
                {
                    Id             = item.Id,
                    Name           = item.Name,
                    TotalAmount    = amoutOfIngredientsInDishes,
                    NumberOfDishes = numberOfIngredientsInDishes
                };
                ingredientsUsageList.Add(ingredientsUsage);
            }
            return(ingredientsUsageList);
        }
        public IActionResult GenerateReportPdf()
        {
            var ingredients = _ingredientsRepository.GetIngredients();
            var itemList    = _itemListRepository.GetAll();

            return(_recipeService.CreatePdfReport(ingredients.ToList(), itemList.ToList()));
        }
Exemple #3
0
        public ActionResult <IEnumerable <Ingredient> > Get()
        {
            var list = _ingredientsRepository.GetIngredients();
            var dest = _mapper.Map <IReadOnlyList <Domain.Ration.Ingredient.Ingredient>, Ingredient[]>(list);

            return(dest);
        }
Exemple #4
0
 public List <IngredientViewModel> All()
 {
     return(_mapper.Map <List <IngredientViewModel> >(_ingredientsRepository.GetIngredients()));
 }
        public IActionResult GenerateReportPdf()
        {
            IEnumerable <Ingredient> ingredients = _ingredientsRepository.GetIngredients();

            return(_recipeService.CreatePdfReport((List <Ingredient>)ingredients));
        }
 public List <Ingredient> GetIngredients()
 {
     return(_ingredientsRepository.GetIngredients());
 }
 public void Test_GetIngredients()
 {
     Assert.IsTrue(_ingredientsRepository.GetIngredients().Count() == 4);
 }