Exemplo n.º 1
0
        //Xóa Ingredient
        public async Task <bool> Delete(object id)
        {
            var brand = _repoIngredient.FindById(id.ToInt());

            _repoIngredient.Remove(brand);
            return(await _repoIngredient.SaveAll());
        }
Exemplo n.º 2
0
        // Xóa Ingredient
        public async Task <bool> Delete(object id)
        {
            string token  = _accessor.HttpContext.Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            if (userID == 0)
            {
                return(false);
            }
            var ingredient = _repoIngredient.FindById(id.ToInt());

            ingredient.isShow       = false;
            ingredient.ModifiedBy   = userID;
            ingredient.ModifiedDate = DateTime.Now;
            return(await _repoIngredient.SaveAll());
        }
Exemplo n.º 3
0
        public async Task <IngredientResponse> DeleteAsync(int id)
        {
            var existingIngredient = await _ingredientRepository.FindById(id);

            if (existingIngredient == null)
            {
                return(new IngredientResponse("Ingredient not found"));
            }
            try
            {
                _ingredientRepository.Remove(existingIngredient);
                await _unitOfWork.CompleteAsync();

                return(new IngredientResponse(existingIngredient));
            }
            catch (Exception ex)
            {
                return(new IngredientResponse($"An error ocurred while deleting Ingredient: {ex.Message}"));
            }
        }
Exemplo n.º 4
0
 public double GetIngredientStock(int ingredientId)
 {
     return(_ingredientRepository.FindById(ingredientId).Stock);
 }
Exemplo n.º 5
0
 public IEnumerable <Ingredient> GetDishIngredients(Dish dish)
 {
     return(dish.IngredientIds
            .Select(ingredientId => _ingredientRepository
                    .FindById(ingredientId)));
 }
Exemplo n.º 6
0
 .Select(ingredientId => _ingredientRepository.FindById(ingredientId))
 .ToList());