public void BuyDrink(DrinkSubmitModel model) { var drink = context.Drinks.FirstOrDefault(d => d.Id == model.Id); if (drink == null) return; drink.Quantity = drink.Quantity >= model.Quantity ? drink.Quantity - model.Quantity : 0; context.SaveChanges(); }
public void BuyDrink(DrinkSubmitModel model) { }
public ActionResult BuyDrink(DrinkSubmitModel model) { repositoryDrinks.BuyDrink(model); return View("Drinks", repositoryDrinks.GetDrinks().Where(d=>d.Quantity > 0).OrderBy(d=>d.Price)); }