コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,LocationId,CustomerId,OrderDate,Total")] Orders orders)
        {
            if (id != orders.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orders);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrdersExists(orders.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "FirstName", orders.CustomerId);
            ViewData["LocationId"] = new SelectList(_context.Locations, "Id", "Address", orders.LocationId);
            return(View(orders));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,CardNumber")] Customers customers)
        {
            if (id != customers.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomersExists(customers.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customers));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,LocationId,ProductId,Stock")] Inventory inventory)
        {
            if (id != inventory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(inventory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InventoryExists(inventory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LocationId"] = new SelectList(_context.Locations, "Id", "Address", inventory.LocationId);
            ViewData["ProductId"]  = new SelectList(_context.Products, "Id", "Name", inventory.ProductId);
            return(View(inventory));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Address,City,State")] Locations locations)
        {
            if (id != locations.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(locations);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocationsExists(locations.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(locations));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Category,Price")] Products products)
        {
            if (id != products.Id)
            {
                return(NotFound());
            }

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