Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("OrderId,CustomerId,FoodType,Amount,Price")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "CustomerId", "CustomerId", order.CustomerId);
            return(View(order));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("CustomerId,FirstName,LastName,Address")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                if (!User.Identity.IsAuthenticated)
                {
                    return(Redirect("/Identity/Account/Login"));
                }
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }