コード例 #1
0
        public async Task <IActionResult> Edit(
            int id, [Bind("Id,name")] Country country
            )
        {
            if (id != country.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(country);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CountryExists(country.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(
            int id,
            [Bind(@"Id,sku,name,description,price,msrp,inventory,image,hot,createdAt,
              updatedAt")]
            Product product
            )
        {
            if (id != product.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(
            int id,
            [Bind("Id,email,createdAt,updatedAt")] Client client)
        {
            if (id != client.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(
            int id,
            [Bind(@"Id,paymentMethod,total,ApiOrderId,status,clientForeignKey,
              productForeignKey")]
            Order order
            )
        {
            if (id != order.Id)
            {
                return(NotFound());
            }

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

            ViewData["clientForeignKey"] = new SelectList(
                _context.Client, "Id", "email", order.clientForeignKey
                );
            ViewData["productForeignKey"] = new SelectList(
                _context.Product, "Id", "description", order.productForeignKey
                );

            return(View(order));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(
            int id,
            [Bind(@"Id,type,firstName,lastName,email,line1,line2,city,zipCode,phone,
              createdAt,updatedAt,countryForeignKey,clientForeignKey")]
            Address address
            )
        {
            if (id != address.Id)
            {
                return(NotFound());
            }

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

            ViewData["clientForeignKey"] = new SelectList(
                _context.Client, "Id", "email", address.clientForeignKey
                );
            ViewData["countryForeignKey"] = new SelectList(
                _context.Country, "Id", "name", address.countryForeignKey
                );

            return(View(address));
        }