Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerOrderId,ProductId,CustomerId,OrderCreated,OrderStatus")] CustomerOrder customerOrder)
        {
            if (id != customerOrder.CustomerOrderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerOrder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerOrderExists(customerOrder.CustomerOrderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerEmail", customerOrder.CustomerId);
            ViewData["ProductId"]  = new SelectList(_context.Products, "ProductId", "Description", customerOrder.ProductId);
            return(View(customerOrder));
        }
        public async Task <IActionResult> Edit(int id, [Bind("CustomerId,CustomerName,CustomerLastName,CustomerPhone,CustomerEmail,CustomerStatus,CustomerCreated")] Customer customer)
        {
            if (id != customer.CustomerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.CustomerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductId,ProductName,Description,Stock,ProductCreated,ProductStatus")] Product product)
        {
            if (id != product.ProductId)
            {
                return(NotFound());
            }

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