예제 #1
0
        public IDataResult <Ingredients> Get(int id)
        {
            var result = _ingredientRepository.Get(x => x.Id == id);

            if (result == null)
            {
                return(new ErrorDataResult <Ingredients>(Messages.IngredientNotFound));
            }
            return(new SuccessDataResult <Ingredients>(result));
        }
예제 #2
0
        public ActionResult <Ingredient> Get(int id)
        {
            var Ingredient = _contentRepository.Get(id);

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

            return(Ingredient);
        }
예제 #3
0
        public async Task <IngredientDto> GetAsync(int id)
        {
            var ingredient = await _ingredientRepository.Get(id);

            if (ingredient == null)
            {
                throw new NotFoundException("Ingredient not found.");
            }

            var dtoIngredient = _mapper.Map <IngredientDto>(ingredient);

            return(dtoIngredient);
        }
예제 #4
0
        // GET: Ingredients/Details/id
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Ingredient ingredient = await _ingredientRepo.Get((Guid)id);

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

            return(View(ingredient));
        }
예제 #5
0
 public Task <Ingredient> Get(int id)
 {
     return(Task.Run(() =>
     {
         return _repository.Get(id);
     }));
 }
예제 #6
0
        public async Task EditIngredient(EditIngredientRequestModel editIngredient)
        {
            var ingredientToUpdate = await _ingredientRepository.Get(editIngredient.Id);

            if (ingredientToUpdate != null)
            {
                ingredientToUpdate.MeasurmentId = editIngredient.MeasurmentId;
                ingredientToUpdate.Title        = editIngredient.Title;
                await _ingredientRepository.Edit(ingredientToUpdate);
            }
        }
        public Drug GetEager(long id)
        {
            Drug drug = base.Get(id);

            foreach (Ingredient ingredient in drug.Ingredients)
            {
                Ingredient temp = _ingredientRepository.Get(ingredient.Id);
                ingredient.Name     = temp.Name;
                ingredient.Quantity = temp.Quantity;
            }

            foreach (Drug alternativeDrug in drug.Alternative)
            {
                Drug temp = base.Get(id);
                alternativeDrug.Name     = temp.Name;
                alternativeDrug.Amount   = temp.Amount;
                alternativeDrug.Approved = temp.Approved;
            }

            return(drug);
        }
 private async Task <Either <string, Ingredient> > RetrieveIngredient(int id) =>
 (await _ingredientRepository.Get(id))
 .ToEither($"Nao foi encontrado um ingrediente com id {id}");
예제 #9
0
 public Ingredient Get(int id)
 {
     return(_ingredientRepo.Get(id));
 }
예제 #10
0
 public async Task <IngredientLogic> Get(int id)
 {
     return(_mapper.Map <IngredientLogic>(await _ingredientRepository.Get(id)));
 }
예제 #11
0
 public Ingredient Get(int id)
 {
     return(ingredientRepository.Get(id));
 }
예제 #12
0
 private async Task <Either <Ingredient, Unit> > Validate(CreateIngredient command) =>
 (await _ingredientRepository.Get(command.Name))
 .ToEither(new Unit())
 .Swap();
 public Ingredient Get(long id)
 {
     return(_ingrerdientRepository.Get(id));
 }
 public async Task <IList <Ingredient> > Handle() =>
 await _ingredientRepository.Get();