public async Task <IActionResult> Edit(int id, [Bind("UserID,ID,OrderTime")] OrderStatus orderStatus)
        {
            if (id != orderStatus.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderStatus);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderStatusExists(orderStatus.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserID"] = new SelectList(_context.User, "ID", "Email", orderStatus.UserID);
            return(View(orderStatus));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("OrderStatusID,ID,Quantity,ItemPrice,TotalPrice,Comment,MenuID")] MenuOrder menuOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(menuOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MenuID"]        = new SelectList(_context.Menu, "ID", "Description", menuOrder.MenuID);
            ViewData["OrderStatusID"] = new SelectList(_context.OrderStatus, "ID", "ID", menuOrder.OrderStatusID);
            return(View(menuOrder));
        }