예제 #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));
        }
예제 #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));
        }
예제 #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));
        }
예제 #4
0
        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();
 }