コード例 #1
0
        public async Task <IActionResult> Create([Bind("ID,Food_Name,Food_Type,Food_Quantity,Price")] Food food)
        {
            if (ModelState.IsValid)
            {
                _context.Add(food);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(food));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("ID,First_Name,Last_Name,Address,Gender,DOB")] Staff staff)
        {
            if (ModelState.IsValid)
            {
                _context.Add(staff);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(staff));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("ID,CustomerID,StaffID,FoodID")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerID"] = new SelectList(_context.Customer, "ID", "ID", order.CustomerID);
            ViewData["FoodID"]     = new SelectList(_context.Food, "ID", "ID", order.FoodID);
            ViewData["StaffID"]    = new SelectList(_context.Set <Staff>(), "ID", "ID", order.StaffID);
            return(View(order));
        }