예제 #1
0
        public async Task <IEnumerable <IngredientDto> > GetAllAsync()
        {
            var ingredients = await _ingredientRepository.GetAll();

            var dtoIngredients = _mapper.Map <IEnumerable <Ingredient>, IEnumerable <IngredientDto> >(ingredients);

            return(dtoIngredients);
        }
예제 #2
0
        public List <Ingredient> GetMedicineIngredients(Medicine medicine)
        {
            List <Ingredient> ingredientsList = new List <Ingredient>();

            foreach (Ingredient ingredient in _ingredientFileRepository.GetAll())
            {
                if (medicine.IngredientsList.Contains(ingredient))
                {
                    ingredientsList.Add(ingredient);
                }
            }
            return(ingredientsList);
        }
예제 #3
0
        public void Load()
        {
            Ingredients.Clear();
            var ingredients = _ingredientRepository.GetAll();

            Ingredients.AddRange(ingredients);
        }
예제 #4
0
 public Task <IEnumerable <Ingredient> > GetAll()
 {
     return(Task.Run(() =>
     {
         return _repository.GetAll();
     }));
 }
예제 #5
0
        public IActionResult GetIngredientsForFood(Guid foodId)
        {
            if (_foodRepository.GetSingle(foodId) == null)
            {
                return(NotFound());
            }

            var allItems = _repository
                           .GetAll()
                           .Where(x => x.FoodItem.Id == foodId)
                           .ToList();

            IEnumerable <IngredientDto> viewModels = allItems
                                                     .Select(x => Mapper.Map <IngredientDto>(x));

            return(Ok(viewModels));
        }
예제 #6
0
        private void ShowIngridients()
        {
            var ingridients = _ingredientRepository.GetAll();

            foreach (var ingridient in ingridients)
            {
                Console.WriteLine($"{ingridient.Id} - {ingridient.Name}");
            }
        }
        public IEnumerable <Drug> GetAllEager()
        {
            IEnumerable <Drug>       drugs       = this.GetAll();
            IEnumerable <Ingredient> ingredients = _ingredientRepository.GetAll();

            BindDrugIngredients(drugs, ingredients);
            BindAlternativeDrugs(drugs);

            return(drugs);
        }
예제 #8
0
        public IEnumerable <Allergy> GetAllEager()
        {
            IEnumerable <Allergy>    allergies   = GetAll();
            IEnumerable <Ingredient> ingredients = _ingredientsRepository.GetAll();
            IEnumerable <Symptom>    symptoms    = _symptomsRepository.GetAll();

            Bind(allergies, ingredients, symptoms);

            return(allergies);
        }
예제 #9
0
        public ActionResult <Ingredient> GetAll()
        {
            var Ingredient = _contentRepository.GetAll();

            if (Ingredient == null)
            {
                return(NotFound());
            }

            return(Ok(new { Ingredient = Ingredient }));
        }
예제 #10
0
        public List <CommonNameDTO> GetAll()
        {
            var ingredients    = _ingredientRepository.GetAll();
            var ingredientDtos = new List <CommonNameDTO>();

            foreach (var item in ingredients)
            {
                ingredientDtos.Add(new CommonNameDTO
                {
                    Name        = item.Name,
                    NameForeign = item.NameForeign
                });
            }

            return(ingredientDtos);
        }
        public IEnumerable <LookupItem> GetAllIngredients()
        {
            var allIngredients = _ingredientRepository.GetAll();

            var ingredientLookups = new List <LookupItem>();

            foreach (var ingredient in allIngredients)
            {
                ingredientLookups.Add(new LookupItem()
                {
                    Id = ingredient.Id, DisplayMember = ingredient.Name
                });
            }

            return(ingredientLookups);
        }
예제 #12
0
 public IEnumerable <Ingredient> GetAll()
 {
     return(_ingredientRepo.GetAll());
 }
예제 #13
0
 // GET: Ingredients
 public async Task <IActionResult> Index()
 {
     return(View(await _ingredientRepo.GetAll()));
 }
예제 #14
0
 public async Task <IList <IngredientLogic> > GetAll()
 {
     return(_mapper.Map <List <IngredientLogic> >(await _ingredientRepository.GetAll()));
 }
예제 #15
0
 public IEnumerable <Ingredient> Get()
 {
     return(_ingredientRepository.GetAll().ToList());
 }
예제 #16
0
        public ActionResult MakeABurger(MakeABurgerPostViewModel makeABurgerPostViewModel)
        {
            User currentUserDb = userRepository.GetAll(x => x.Id == LoginUserSession.Current.UserId).FirstOrDefault();

            if (!ModelState.IsValid)
            {
                TempData["ErrorMessage"] = ModelState.Where(x => x.Value.Errors.Count > 0).FirstOrDefault().Value.Errors.FirstOrDefault().ErrorMessage;
                return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()));
            }
            if (currentUserDb == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (makeABurgerPostViewModel.ChosenBunId <= 0)
            {
                TempData["ErrorMessage"] = "Please select a bun type";
                return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()));
            }
            if (makeABurgerPostViewModel.ChosenIngredientsIds.Count == 0)
            {
                TempData["ErrorMessage"] = "Please select at least 1 ingredient for the burger";
                return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()));
            }
            if (currentUserDb.Burgers.Any(x => x.Name == makeABurgerPostViewModel.BurgerName))
            {
                TempData["ErrorMessage"] = "You have already created a burger with this name!";
                return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()));
            }

            List <Ingredient> chosenIngredients = new List <Ingredient>();

            makeABurgerPostViewModel.ChosenIngredientsIds.ForEach(x => chosenIngredients.Add(ingredientRepository.GetAll(c => c.Id == x).FirstOrDefault()));
            Bun chosenBun = bunRepository.GetAll(x => x.Id == makeABurgerPostViewModel.ChosenBunId).FirstOrDefault();

            currentUserDb.Burgers.Add(new Burger
            {
                Name        = makeABurgerPostViewModel.BurgerName,
                Ingredients = chosenIngredients,
                Bun         = chosenBun
            });

            bool isSaved = dbContext.SaveChanges() > 0;

            if (isSaved)
            {
                TempData["SuccessMessage"] = "Burger created successfully";
            }
            else
            {
                TempData["ErrorMessage"] = "Ooops something went wrong";
            }
            return(Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString()));
        }
예제 #17
0
 //[Authorize(Policy = PermissionsList.PermissionsIngredientIngredients)]
 public IActionResult GetIngredients()
 {
     return(Ok(new { ingredients = _ingredientRepository.GetAll() }));
 }
예제 #18
0
        public IEnumerable <Ingredient> GetAll()
        {
            var ingredients = _ingredientRepository.GetAll();

            return(ingredients);
        }
예제 #19
0
        public IActionResult GetAll()
        {
            var ingredients = _ingredientRepository.GetAll();

            return(Ok(ingredients));
        }
예제 #20
0
 public IList <Ingredient> GetIngredients()
 {
     return(_ingredientRepository.GetAll());
 }
        public async Task <ActionResult> GetAll()
        {
            var ingredientList = await _ingredientRepository.GetAll();

            return(StatusCode(200, ingredientList));
        }
예제 #22
0
 public void Load()
 {
     Ingredients = repository.GetAll()
                   .ToList();
 }
예제 #23
0
 private void Bind(IEnumerable <Medicine> medicine)
 {
     BindMedicineWithDisease(medicine, _diseaseRepository.GetAll());
     BindMedicineWithIngredients(medicine, _ingredientRepository.GetAll());
 }
예제 #24
0
        public Task GetIngredients()
        {
            var ingredients = _ingredientRepository.GetAll().Result;

            return(Clients.All.SendAsync("GetIngredients", ingredients));
        }