public void Test_RecipeInstruction_ToString() { RecipeInstruction instruction = new RecipeInstruction { Sequence = 1, Instruction = "Boil Rice" }; string actual = instruction.ToString(); Assert.Equal("1. Boil Rice", actual); }
public void OnNewRecipe() { CurrentlyHolding.Clear(); _requiredMenus.Clear(); int reqItemsIdx = rdRecipeManager.Seele._currentRecipe.Instructions.Length - 1; print(reqItemsIdx); RecipeInstruction rcpIns = rdRecipeManager.Seele._currentRecipe.Instructions[reqItemsIdx]; foreach (var item in rcpIns.Ingredients) { _requiredMenus.Add(item); } }
//interact only true if the player is need to be working public override bool Interact(FoodItemTag item, rdEntity user) { switch (Status) { case StationStatus.Ready: foreach (RecipeInstruction rm in RecipeMenu) { foreach (FoodItemTag igts in rm.Ingredients) { if (igts == item) { user.DropOffItem(); CurrentInstruction = rm; rdUIManager.UpdateOnHandItem(user.ItemOnHand, user); rdUIManager.UpdateStationPopups(this.gameObject); //TODO multiple cooks CurrentHoldItems.Add(igts); FoodItemTag[] reqs = CurrentInstruction.Ingredients; bool startCooking = CurrentHoldItems.OrderBy(x => x).SequenceEqual(reqs.OrderBy(x => x)); if (startCooking) { StartTask(user); } return(CurrentInstruction.Type == TaskType.Active); } } } break; case StationStatus.Collect: if (user.CollectItem(CurrentInstruction.Result)) { Status = StationStatus.Ready; } RecipeMenu.Remove(CurrentInstruction); CurrentHoldItems.Clear(); //OnHoldInstructionUpdate(); rdUIManager.UpdateOnHandItem(user.ItemOnHand, user); rdUIManager.UpdateStationPopups(this.gameObject); rdRecipeManager.UpdateInstruction(user.ItemOnHand); break; default: return(false); } return(false); }
public void addNotOriginalRecipe(Recipe oldrecipe, int id) { Recipe newrecipe = new Recipe(oldrecipe); if (oldrecipe.original == -1) { newrecipe.original = oldrecipe.recipeID; } else { newrecipe.original = oldrecipe.original; } _context.Recipe.Add(newrecipe); _context.SaveChanges(); _context.RecipeBook.Add(new RecipeBook(newrecipe.recipeID, id)); _context.SaveChanges(); int i = 0; foreach (Instruction inst in oldrecipe.instrucoes) { Instruction newInst = new Instruction(inst); _context.Instruction.Add(newInst); _context.SaveChanges(); RecipeInstruction ri = new RecipeInstruction(newrecipe.recipeID, newInst.instructionID, i); i++; _context.RecipeInstruction.Add(ri); _context.SaveChanges();//colocar fora do ciclo probably } foreach (Ingredient ing in oldrecipe.ingredients) { Ingredient newIng = new Ingredient(ing); _context.Ingredient.Add(newIng); _context.SaveChanges(); RecipeIngredient ring = new RecipeIngredient(newrecipe.recipeID, newIng.ingredientID, ing.quant); _context.RecipeIngredient.Add(ring); _context.SaveChanges();//colocar fora do ciclo } }
private RecipeInstructions BuildInstructions(Values <CreativeWork, ItemList, string>?recipeInstructions) { if (!recipeInstructions.HasValue) { return(null); } RecipeInstructions instructions = new RecipeInstructions(); if (recipeInstructions.Value.Values3.HasValue) { int counter = 0; foreach (var i in recipeInstructions.Value.Values3.List) { RecipeInstruction instr = new RecipeInstruction { Sequence = ++counter, Instruction = i }; instructions.Add(instr); } } return(instructions.Count > 0 ? instructions : null); }
public void cleanNotOriginalRecipe(int recipeID) { List <Instruction> instlist = getInstructions(recipeID); foreach (Instruction inst in instlist) { RecipeInstruction ri = _context.RecipeInstruction.Find(recipeID, inst.instructionID); _context.RecipeInstruction.Remove(ri); _context.SaveChanges(); //colocar fora do ciclo probably _context.Instruction.Remove(inst); _context.SaveChanges(); //colocar fora do ciclo probably } List <Ingredient> inglist = getIngredients(recipeID); foreach (Ingredient ing in inglist) { RecipeIngredient ri = _context.RecipeIngredient.Find(recipeID, ing.ingredientID); _context.RecipeIngredient.Remove(ri); _context.SaveChanges(); //colocar fora do ciclo _context.Ingredient.Remove(ing); _context.SaveChanges(); //colocar fora do ciclo } }
public IActionResult Add([FromBody] RecipeInstruction recipeInstruction) { _context.RecipeInstruction.Add(recipeInstruction); _context.SaveChanges(); return(new CreatedResult($"/api/recipeIngredient/{recipeInstruction.recipeID}/{recipeInstruction.instructionID}", recipeInstruction)); }
public void UpdateRecipeInstruction(RecipeInstruction RecipeInstruction) { _dbContext.Entry(RecipeInstruction).State = EntityState.Modified; Save(); }
public void AddRecipeInstruction(RecipeInstruction RecipeInstruction) { _dbContext.Add(RecipeInstruction); Save(); }
public override void Populate(ReferenceInfoDto referenceInfo) { if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Name)) { Recipe.Name = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Name].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Subtitle)) { Recipe.Subtitle = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Subtitle].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Image)) { Recipe.ImageUrl = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Image].ValueUrl; Recipe.ImageText = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Image].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Abstract)) { Recipe.Abstract = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Abstract].ValueText; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Tips)) { Recipe.Tips = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Tips].ValueHtml; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.PrepareTime)) { Recipe.PrepareTimeMinutes = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.PrepareTime].ValueInt; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.CookTime)) { Recipe.CookTimeMinutes = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.CookTime].ValueInt; } if (referenceInfo.ValuesDic.ContainsKey(BlockRegister.RecipeBlock.Servings)) { Recipe.Servings = referenceInfo.ValuesDic[BlockRegister.RecipeBlock.Servings].ValueInt; } SubitemInfoDto ingredientSubitem = BlockInfo.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.RecipeBlock.IngredientGrid)); object ingredientGridId = null; if (ingredientSubitem != null && ingredientSubitem.Grid != null) { ingredientGridId = ingredientSubitem.Grid.Id; } SubitemInfoDto instructionSubitem = BlockInfo.Subitems.SingleOrDefault(o => object.Equals(o.SubitemId, BlockRegister.RecipeBlock.InstructionGrid)); object instructionGridId = null; if (instructionSubitem != null && instructionSubitem.Grid != null) { instructionGridId = instructionSubitem.Grid.Id; } if (referenceInfo.GridRows != null) { foreach (GridRowDto row in referenceInfo.GridRows.Where(o => object.Equals(o.GridId, ingredientGridId))) { RecipeIngredient item = new RecipeIngredient(); Recipe.RecipeIngredients.Add(item); DucValueDto valueOrder = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_Sortorder)); if (valueOrder != null) { item.Sortorder = valueOrder.ValueInt.HasValue ? valueOrder.ValueInt.Value : 0; } DucValueDto valueIngredientName = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_IngredientName)); if (valueIngredientName != null) { item.IngredientName = valueIngredientName.ValueText; } DucValueDto valueQuantity = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_Quantity)); if (valueQuantity != null) { item.Quantity = valueQuantity.ValueText; } DucValueDto valueUnitOfMeasure = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeIngredientGrid.Col_UnitOfMeasure)); if (valueUnitOfMeasure != null) { item.UnitOfMeasure = valueUnitOfMeasure.ValueText; } } foreach (GridRowDto row in referenceInfo.GridRows.Where(o => object.Equals(o.GridId, instructionGridId))) { RecipeInstruction item = new RecipeInstruction(); Recipe.RecipeInstructions.Add(item); DucValueDto valueOrder = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeInstructionGrid.Col_Sortorder)); if (valueOrder != null) { item.Sortorder = valueOrder.ValueInt.HasValue ? valueOrder.ValueInt.Value : 0; } DucValueDto valueDescription = row.Cells.SingleOrDefault(o => object.Equals(o.DucId, BlockRegister.RecipeInstructionGrid.Col_Description)); if (valueDescription != null) { item.Description = valueDescription.ValueText; } } } // Keyword view model TagsViewModel = new ReferenceKeywordsViewModel(referenceInfo); SocialShareBarViewModel = new SocialShareBarViewModel(RequestedUrl.AbsoluteUri, Recipe.Name, Recipe.ImageUrl); }
public ActionResult <RecipeInstruction> UpdateRecipeInstruction(RecipeInstruction RecipeInstruction) { _service.UpdateRecipeInstruction(RecipeInstruction); return(RecipeInstruction); }
public ActionResult <RecipeInstruction> AddRecipeInstruction(RecipeInstruction RecipeInstruction) { _service.AddRecipeInstruction(RecipeInstruction); return(RecipeInstruction); }