//Xóa Ingredient public async Task <bool> Delete(object id) { var brand = _repoIngredient.FindById(id.ToInt()); _repoIngredient.Remove(brand); return(await _repoIngredient.SaveAll()); }
// 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()); }
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}")); } }
public double GetIngredientStock(int ingredientId) { return(_ingredientRepository.FindById(ingredientId).Stock); }
public IEnumerable <Ingredient> GetDishIngredients(Dish dish) { return(dish.IngredientIds .Select(ingredientId => _ingredientRepository .FindById(ingredientId))); }
.Select(ingredientId => _ingredientRepository.FindById(ingredientId)) .ToList());