public async Task <IActionResult> Edit(int id, [Bind("Name, Calories, Origin")] Seasoning seasoning, [Bind("Id,Hotness")] Herbs herbs) { if (id != herbs.Id) { return(NotFound()); } if (ModelState.IsValid) { try { seasoning.Id = id; _context.Seasoning.Update(seasoning); _context.Update(herbs); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HerbsExists(herbs.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Id"] = new SelectList(_context.Seasoning, "Id", "Id", herbs.Id); return(View(herbs)); }
}//Start public bool TryAttractByRecepe(ref Brain b, ref Seasoning s, ref Drink d) { int chance = 0; if (b.Count >= RecepePref.BrainsRange.x && b.Count <= RecepePref.BrainsRange.y) chance += 35; if(s.Count >= RecepePref.SeasoningRange.x && s.Count <= RecepePref.SeasoningRange.y) chance += 35; if (d.Count >= RecepePref.DrinksRange.x && d.Count <= RecepePref.DrinksRange.y) chance += 35; int randomValue = Random.Range(1, 100); return randomValue >= 1 && randomValue <= chance; }//TryAttractByRecepe
public async Task <IActionResult> Create([Bind("Name, Calories, Origin")] Seasoning seasoning, [Bind("Hotness")] Herbs herbs) { if (ModelState.IsValid) { _context.Seasoning.Add(seasoning); herbs.Id = seasoning.Id; _context.Add(herbs); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Id"] = new SelectList(_context.Seasoning, "Id", "Id", herbs.Id); return(View(herbs)); }