public ActionResult DeleteFromRecipe(int idRecipe, int idIngredient) { if (IngredientsDAO.DeleteFromRecipe(idRecipe, idIngredient)) { return(Ok()); } return(BadRequest()); }
public ActionResult Delete(int id) { if (IngredientsDAO.Delete(id)) { return(Ok()); } return(BadRequest()); }
public ActionResult PutInRecipe([FromBody] UsedIngredientsDTO ingredientDto) { if (IngredientsDAO.UpdateInRecipe(ingredientDto)) { return(Ok()); } return(BadRequest()); }
public List <CocktailModel> GetNewGeneratedCocktail(int numberOfIngridients, double finalPercentageOfAlcohol, string drinkName) { List <CocktailModel> cocktailReturnColl = new List <CocktailModel>(); CocktailModel cocktailReturn = null; List <IngredientModel> ingredientColl = null; cocktailDAO = new CocktailDAO(); ingredientsDAO = new IngredientsDAO(); if (numberOfIngridients == 0) { numberOfIngridients = 2; } if (finalPercentageOfAlcohol == 0) { finalPercentageOfAlcohol = 0.15; } ingredientColl = ingredientsDAO.ListAll(); cocktailReturn = new CocktailModel(); cocktailReturn.Name = "".Equals(drinkName) ? "New Drink" : drinkName; Random r = new Random(); for (int i = 0; i < numberOfIngridients; i++) { int x = r.Next(ingredientColl.Count); var ingridient = ingredientColl[x]; if (cocktailReturn.OrderIngredient == null) { cocktailReturn.OrderIngredient = new List <IngredientModel>(); cocktailReturn.OrderIngredient.Add(ingridient); } else { if (cocktailReturn.OrderIngredient.Exists(item => item.Name == "Champagne")) { if (ingridient.Name.Equals("Campari")) { cocktailReturn.OrderIngredient.Add(ingredientColl.Single(item => item.Name != "Campari")); } } else if (cocktailReturn.OrderIngredient.Exists(item => item.Name == "Campari")) { { if (ingridient.Name.Equals("Champagne")) { cocktailReturn.OrderIngredient.Add(ingredientColl.Single(item => item.Name != "Champagne")); } } } else { cocktailReturn.OrderIngredient.Add(ingridient); } } } if (Util.Utils.SumAlcohol(cocktailReturn.OrderIngredient) <= finalPercentageOfAlcohol) { cocktailReturn.HexadecimalColor = Util.Utils.GetHexaDrink(cocktailReturn.OrderIngredient); cocktailReturn.PercentageOfAlcohol = Util.Utils.SumAlcohol(cocktailReturn.OrderIngredient); cocktailReturnColl.Add(cocktailReturn); } return(cocktailReturnColl); }
public UsedIngredientsDTO PostToRecipe([FromBody] UsedIngredientsDTO ingredientDto) { return(IngredientsDAO.PostToRecipe(ingredientDto)); }
public IngredientsDTO Post([FromBody] IngredientsDTO ingredientDto) { return(IngredientsDAO.Post(ingredientDto)); }
public IEnumerable <UsedIngredientsDTO> GetFromRecipe(int recipeId) { return(IngredientsDAO.QueryFromRecipe(recipeId)); }
public IEnumerable <IngredientsDTO> Get() { return(IngredientsDAO.Query()); }