public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ImageUrl,Price")] Candies candies) { if (id != candies.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(candies); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CandiesExists(candies.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(candies)); }
public void TestPrizes() { var candies = new Candies(); var prizes = candies.NoOfPrizes(8); Assert.IsTrue(prizes[0] == 1 && prizes[1] == 2 && prizes[2] == 5); }
public async Task <IActionResult> Create([Bind("Id,Name,ImageUrl,Price")] Candies candies) { if (ModelState.IsValid) { _context.Add(candies); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(candies)); }
static void Main(string[] args) { // client code Cake cake1 = new ButterCake(); cake1 = new ChocolateDrip(cake1); cake1 = new FreshFruit(cake1); System.Console.WriteLine(cake1.get_description() + ": $" + cake1.cost()); Cake cake2 = new SpongeCake(); cake2 = new WhippedCream(cake2); cake2 = new Candies(cake2); System.Console.WriteLine(cake2.get_description() + ": $" + cake2.cost()); }
public static void Main(string[] args) { Console.WriteLine(Candies.CountCandies(3, 2)); }
public List <Candy> FindBySugar(double minSugarWeight, double maxSugarWeight) { return(Candies.Where(candy => candy.SugarWeight >= minSugarWeight && candy.SugarWeight <= maxSugarWeight).ToList()); }
public List <Candy> Sort(string property) { return(Candies.OrderBy(p => p.GetType() .GetProperty(property) .GetValue(p, null)).ToList()); }
public void Add(Candy candy) { Candies.Add(candy); Weight += candy.Weight; }