public async Task <IActionResult> Create([Bind("ID,Name")] Menu menu) { if (ModelState.IsValid) { _context.Menus.Add(menu); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(menu)); }
public async Task <IActionResult> Create([Bind("ID,Name")] DrinkCategory drinkCategory) { if (ModelState.IsValid) { _context.Add(drinkCategory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(drinkCategory)); }
public async Task <IActionResult> Create([Bind("Id,Name,Description,CategoryID")] Drink drink) { if (ModelState.IsValid) { _context.Drinks.Add(drink); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewBag.Category = new SelectList(_context.Categories, "ID", "Name"); return(View(drink)); }
public async Task <IActionResult> Create([Bind("MenuID,DrinkID")] DrinkMenu drinkMenu) { if (ModelState.IsValid) { _context.Add(drinkMenu); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DrinkID"] = new SelectList(_context.Drinks, "Id", "Id", drinkMenu.DrinkID); ViewData["MenuID"] = new SelectList(_context.Menus, "ID", "ID", drinkMenu.MenuID); return(View(drinkMenu)); }
public async void Save() { await Context.SaveChangesAsync(); }