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

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(snackCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SnackCategoryExists(snackCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(snackCategory));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Price,ShortDescription,LongDescription,MainImage,MainThumbnail,IsStarred,IsAvailable,SnackCategoryId")] Snack snack)
        {
            if (id != snack.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(snack);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SnackExists(snack.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SnackCategoryId"] = new SelectList(_context.SnackCategories, "Id", "Name", snack.SnackCategoryId);
            return(View(snack));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("OrderId,Name,SirName,Address,AddressComplement,PostalCode,Province,City,PhoneNumber,EmailAddress,Total,OrderDate,DepartureTime,DeliveredTime")] 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)));
            }
            return(View(order));
        }