コード例 #1
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Menu menu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(menu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(menu));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,MenuId,SectionId,Name,Description,Price")] Menuitem menuitem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(menuitem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MenuId"]    = new SelectList(_context.Menu, "Id", "Id", menuitem.MenuId);
            ViewData["SectionId"] = new SelectList(_context.Section, "Id", "Id", menuitem.SectionId);
            return(View(menuitem));
        }