public async Task <ActionResult> Index(int?page, string searchText)
        {
            var totalIngredients = await _ingredientsRepository.GetTotalCountAsync(searchText);

            Pager pager = new Pager(totalIngredients, page);

            var ingredients = _ingredientsRepository.GetAll(searchText)
                              .Skip((pager.CurrentPage - 1) * pager.PageSize)
                              .Take(pager.PageSize);

            var viewModel = new IngredientsIndexViewModel()
            {
                Ingredients = ingredients,
                Pager       = pager,
                SearchText  = searchText
            };

            return(View(viewModel));
        }
示例#2
0
 public void AddIngredientCustom_ShouldWork()
 {
     RunOnDatabase(async s =>
     {
         DestroyDatabase();
         // Arrange
         var fridgeRepo    = new FridgeRepository(s);
         var ingredCatRepo = new IngredientsCategoryRepository(s);
         var ingredRepo    = new IngredientsRepository(s, ingredCatRepo, fridgeRepo);
         var recipeRepo    = new RecipesRepository(s, fridgeRepo, ingredRepo);
         IEnumerable <IngredientCategory> categories = GetDefaultCategories();
         // Act
         Populate(s);
         int count = ingredRepo.GetAll().Result.Count();
         await ingredRepo.AddIngredientCustom(recipeRepo.GetAll().Result.First().Id, "t", "ms", "new", 1, 1, 1);
         await ingredRepo.AddIngredientCustom(recipeRepo.GetAll().Result.First().Id, "First Category", "i3", "cup", 1, 1, 1);
         //await ingredRepo.AddIngredientCustom(recipeRepo.GetAll().Result.First().Id, "Another Category", "i3", "cup", 1, 1, 1);
         await ingredRepo.AddIngredientCustom(recipeRepo.GetAll().Result.First().Id, "asfasfasfasfy", "i5", "cup", 1, 1, 1);
         // Assert
         Assert.AreEqual(count + 3, ingredRepo.GetAll().Result.Count());
     });
 }
示例#3
0
 public List <IngredientsViewPar> GetAll()
 {
     using (var ingredient = new IngredientsRepository())
     {
         return(ingredient.GetAll().Select(x => new IngredientsViewPar
         {
             IngredientId = x.IngredientId,
             IngredientName = x.IngredientName,
             NumIngredients = x.NumIngredients,
             IngredientMass = x.IngredientMass,
             Ingredientprice = x.Ingredientprice,
             TotalPrice = x.TotalPrice,
             TotalMass = x.TotalMass,
         }).ToList());
     }
 }
 public List <TreatmentRatioViewPar> GetAll()
 {
     using (var ingredient = new TreatmentRatioRepository())
     {
         return(ingredient.GetAll().Select(x => new TreatmentRatioViewPar
         {
             TreatmentRatioId = x.TreatmentRatioId,
             IngredientName = _ingredients.GetAll().ToList().Find(y => y.IngredientId == x.IngredientId).IngredientName,
             TotalMass = x.TotalMass,
             TreatPrice = x.TreatPrice,
             TreatmentPercentage = (_percentage.GetAll().ToList().Find(y => y.TreatmentPercentageId == x.TreatmentPercentageId).Percentage),
             TreatmentName = _treatment.GetAll().ToList().Find(y => y.Tid == x.Tid).Tname
         }).ToList());
     }
 }
 internal IEnumerable <Ingredient> GetAll()
 {
     return(_repo.GetAll());
 }
示例#6
0
 public List <Ingredients> GetAll()
 {
     return(_repo.GetAll());
 }