private void btnRecalculate_Click(object sender, EventArgs e) { // Create a new bake from the text entered Bake _newBake = new Bake(double.Parse(txtFlour.Text), double.Parse(txtSalt.Text), double.Parse(txtYeast.Text), double.Parse(txtWater.Text)); // Construct a new bake using the old one as a reference for ratios if (_newBake.Flour != _currentBake.Flour) { _newBake = BakeLogic.Recalculate(_currentBake, _newBake, 1); } else if (_newBake.Salt != _currentBake.Salt) { _newBake = BakeLogic.Recalculate(_currentBake, _newBake, 2); } else if (_newBake.Yeast != _currentBake.Yeast) { _newBake = BakeLogic.Recalculate(_currentBake, _newBake, 3); } else if (_newBake.Water != _currentBake.Water) { _newBake = BakeLogic.Recalculate(_currentBake, _newBake, 4); } // Output the new amounts of ingredients txtFlour.Text = _newBake.Flour.ToString("N0"); txtSalt.Text = _newBake.Salt.ToString("N0"); txtYeast.Text = _newBake.Yeast.ToString("N0"); txtWater.Text = _newBake.Water.ToString("N0"); _currentBake = new Bake(double.Parse(txtFlour.Text), double.Parse(txtSalt.Text), double.Parse(txtYeast.Text), double.Parse(txtWater.Text)); }
public ActionResult DeleteConfirmed(int id) { Bake bake = db.Bakes.Find(id); db.Bakes.Remove(bake); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "BakeID,Name,Price,Description")] Bake bake) { if (ModelState.IsValid) { db.Entry(bake).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bake)); }
public ActionResult Create([Bind(Include = "BakeID,Name,Price,Description")] Bake bake) { if (ModelState.IsValid) { db.Bakes.Add(bake); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bake)); }
public frmMain() { InitializeComponent(); // A default setting for a sourdough loaf txtFlour.Text = "500"; txtSalt.Text = "15"; txtYeast.Text = "50"; txtWater.Text = "350"; // Save this bake information from which to calculate ratios _currentBake = new Bake(int.Parse(txtFlour.Text), int.Parse(txtSalt.Text), int.Parse(txtYeast.Text), int.Parse(txtWater.Text)); }
// GET: Bake/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Bake bake = db.Bakes.Find(id); if (bake == null) { return(HttpNotFound()); } return(View(bake)); }
static void Main(string[] args) { Bake bake = new Bake(); bake.TemperatureProp = 1; Console.WriteLine(bake.TemperatureProp); ElectricBake electricBake = new ElectricBake(); electricBake.TemperatureProp = 16; Ivan ivan = new Ivan(); ivan.OnBake; }
public when_my_cake_is_strawberry_cheese_cake() { _context = () => { MyCake = new Domain.Cake { Type = CakeType.FlourlessCheese, Toppings = new List <Top> { new Top { Name = "Strawberry" } } }; MyBaking = new Bake(); }; }
public static Bake Recalculate(Bake previousBake, Bake bakeIn, int choice) { double bakeOutFlour = bakeIn.Flour; double bakeOutSalt = bakeIn.Salt; double bakeOutYeast = bakeIn.Yeast; double bakeOutWater = bakeIn.Water; switch (choice) { case 1: bakeOutSalt = bakeIn.Flour * (bakeIn.Salt / previousBake.Flour); bakeOutYeast = bakeIn.Flour * (bakeIn.Yeast / previousBake.Flour); bakeOutWater = bakeIn.Flour * (bakeIn.Water / previousBake.Flour); break; case 2: bakeOutFlour = bakeIn.Salt * (bakeIn.Flour / previousBake.Salt); bakeOutYeast = bakeIn.Salt * (bakeIn.Yeast / previousBake.Salt); bakeOutWater = bakeIn.Salt * (bakeIn.Water / previousBake.Salt); break; case 3: bakeOutFlour = bakeIn.Yeast * (bakeIn.Flour / previousBake.Yeast); bakeOutSalt = bakeIn.Yeast * (bakeIn.Salt / previousBake.Yeast); bakeOutWater = bakeIn.Yeast * (bakeIn.Water / previousBake.Yeast); break; case 4: bakeOutFlour = bakeIn.Water * (bakeIn.Flour / previousBake.Water); bakeOutSalt = bakeIn.Water * (bakeIn.Salt / previousBake.Water); bakeOutYeast = bakeIn.Water * (bakeIn.Yeast / previousBake.Water); break; default: System.Console.WriteLine("You can't create a bake without first entering at least one ingredient."); break; } return(new Bake(bakeOutFlour, bakeOutSalt, bakeOutYeast, bakeOutWater)); }
public void OnBake(Bake bake) { bake.OnBake(); }