Example #1
0
        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));
        }
Example #2
0
        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));
        }
Example #3
0
        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();
 }