public async Task <IActionResult> Edit(int id, [Bind("CustId,CustFirstName,CustSurName")] CafeCustomers cafeCustomers)
        {
            if (id != cafeCustomers.CustId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cafeCustomers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CafeCustomersExists(cafeCustomers.CustId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cafeCustomers));
        }
        public async Task <IActionResult> Edit(int id, [Bind("OrderId,OrderDate,CustomerId")] Orders orders)
        {
            if (id != orders.OrderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orders);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrdersExists(orders.OrderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerId", orders.CustomerId);
            return(View(orders));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProductId,ProductType,ProductPrice,ProductName,ProductCalories,ProductDetails")] CafeProducts cafeProducts)
        {
            if (id != cafeProducts.ProductId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cafeProducts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CafeProductsExists(cafeProducts.ProductId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Menu)));
            }
            return(View(cafeProducts));
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductId,ProductDetails,Price,Quantity,Reordering,MinimumStock")] Products products)
        {
            if (id != products.ProductId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(products);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductsExists(products.ProductId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(products));
        }