public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Number,Price")] 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));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,ShoppingDate,Store,Sum")] ShoppingDay shoppingDay)
        {
            if (id != shoppingDay.ID)
            {
                return(NotFound());
            }

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