コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerID,Name,Adress,BirthDate")] 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));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,CustomerID,Total,NumarFactura")] Bill bill)
        {
            if (id != bill.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bill);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BillExists(bill.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerID"] = new SelectList(_context.Customers, "CustomerID", "CustomerID", bill.CustomerID);
            return(View(bill));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderID,CustomerID,LaptopID,OrderDate")] Order order)
        {
            if (id != order.OrderID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.OrderID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerID"] = new SelectList(_context.Customers, "CustomerID", "CustomerID", order.CustomerID);
            ViewData["LaptopID"]   = new SelectList(_context.Laptops, "ID", "ID", order.LaptopID);
            return(View(order));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Brand_Name,Processor,Price")] Laptop laptop)
        {
            if (id != laptop.ID)
            {
                return(NotFound());
            }

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