Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, Item item)
        {
            if (id != item.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                Item updatedItem;
                try
                {
                    updatedItem = await _invoicesRepository.UpdateItemAsync(item);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await _invoicesRepository.ItemExistsAsync(item.Id))
                    {
                        return(NotFound());
                    }

                    throw;
                }

                if (updatedItem != null)
                {
                    return(RedirectToAction("Details", "Invoices", new { id = updatedItem.InvoiceId }));
                }
                else
                {
                    return(RedirectToAction("Index", "Invoices"));
                }
            }
            return(View(item));
        }