/// <summary> /// ExecuteLoadRecipeStepCommand Method /// </summary> /// /// <remarks> /// An async Method which executes a command. In this case creates a List of the RecipeSteps of the current /// Recipe Item. /// </remarks> /// /// <returns> /// Task Object -- Used with Threading /// </returns> async Task ExecuteLoadRecipeStepCommand() { if (IsBusy) { return; } IsBusy = true; try { RecipeSteps.Clear(); var items = await DataStore.GetItemAsync(Item.Id); foreach (var recipeStep in items.RecipeSteps) { RecipeSteps.Add(recipeStep); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public Recipe(CreateRecipeDto createRecipeDto) { Title = createRecipeDto.Title; Description = createRecipeDto.Description; Saved = createRecipeDto.Saved; createRecipeDto.RecipeSteps?.ForEach(step => { var recipeStep = new RecipeStep(step); RecipeSteps.Add(recipeStep); }); }
public void ToggleTextEditting(EditableRecipeStep step) { if (!IsEditting) { return; } bool currentVal = step.IsEditting; RecipeSteps.ForEach(s => s.IsEditting = false); RecipeSteps.ForEach(s => s.IsOrderEditting = false); step.IsEditting = !currentVal; Focus(); }
public static void ShuffleRecipeSteps(ref RecipeSteps[] arrayToDesorder) { System.Random rng = new System.Random(); int n = arrayToDesorder.Length; while (n > 1) { n--; int k = rng.Next(n + 1); RecipeSteps value = arrayToDesorder[k]; arrayToDesorder[k] = arrayToDesorder[n]; arrayToDesorder[n] = value; } }
public void ToggleOrderEditting(EditableRecipeStep step) { if (!IsEditting) { return; } var currentSelected = RecipeSteps.FirstOrDefault(s => s.IsOrderEditting); if (currentSelected != null) { startDragStep = currentSelected; Drop(step); return; } bool currentVal = step.IsOrderEditting; RecipeSteps.ForEach(s => s.IsOrderEditting = false); RecipeSteps.ForEach(s => s.IsEditting = false); step.IsOrderEditting = !currentVal; }
public IActionResult ViewRecipe(int id, int portion = 4) { if (portion < 1) { portion = 1; } ViewProducts vp = new ViewProducts(); using (SqlConnection con = new SqlConnection("Server=(localdb)\\Mssqllocaldb; Database= TranbarDB; MultipleActiveResultSets=true")) { con.Open(); string SQL = @"select Recipename,EstimatedTime, ProductName, ProductQuantity,Measurement,RE.Id, PR.Id from Products PR INNER JOIN RecipeDetails RD ON PR.ID = RD.ProductID INNER JOIN MeasurementUnit MU ON RD.MeasurementUnitID = MU.Id INNER JOIN Recipe RE ON RD.RecipeID = RE.ID where RE.Id = @ID"; SqlCommand cmd = new SqlCommand(SQL, con); cmd.Parameters.AddWithValue("@ID", id); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { ShowIngrediens SI = new ShowIngrediens(); vp.RecipeID = rdr.GetInt32(5); vp.RecipeName = rdr.GetString(0); vp.EstimatedTime = rdr.GetInt32(1); SI.ProductName = rdr.GetString(2); SI.ProductQuantity = rdr.GetDecimal(3); SI.Measurement = rdr.GetString(4); vp.Productslist.Add(SI); } con.Close(); // Andra queryn -- Hämtar Stegnr och instruktioner con.Open(); string SQL2 = @"select Stepnumber, Instructions from Recipe r inner join RecipeSteps rs on rs.RecipeID = r.ID where r.ID = @ID2"; SqlCommand command = new SqlCommand(SQL2, con); command.Parameters.AddWithValue("@ID2", id); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { RecipeSteps RS = new RecipeSteps(); RS.Stepnumber = reader.GetInt32(0); RS.Instructions = reader.GetString(1); vp.StepList.Add(RS); } con.Close(); } vp.Portion = portion; if (portion >= 1) { vp.Productslist.ForEach(pl => { pl.ProductQuantity = portion * (pl.ProductQuantity * 1 / 4); }); } ; return(View(vp)); }