Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("Id,Text,Price,Active,Order,Type,Day,MenuCardId")] Menu menu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(menu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MenuCardId"] = new SelectList(_context.MenuCards, "Id", "Id", menu.MenuCardId);
            return(View(menu));
        }
        public async Task <IActionResult> Create(Menu menu)
        {
            if (ModelState.IsValid)
            {
                _context.Menus.Add(menu);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["MenuCardId"] = new SelectList(_context.MenuCards, "Id", "MenuCard", menu.MenuCardId);
            return(View(menu));
        }
 public async Task AddMenuAsync(Menu menu)
 {
     _menuCardsContext.Menus.Add(menu);
     await _menuCardsContext.SaveChangesAsync();
 }