public async Task <IActionResult> Edit(int productID, int invoiceID, [Bind("ProductID,InvoiceID,Quantity")] ProductInvoice productInvoice)
        {
            if (productID != productInvoice.ProductID || invoiceID != productInvoice.InvoiceID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productInvoice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductInvoiceExists(productInvoice.ProductID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InvoiceID"] = new SelectList(_context.Invoices, "InvoiceNumber", "InvoiceNumber", productInvoice.InvoiceID);
            ViewData["ProductID"] = new SelectList(_context.Products, "ProductID", "Name", productInvoice.ProductID);
            return(View(productInvoice));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("BankAccountNumber,CompanyID,CompanyName,Street,City,ZipCode")] Supplier supplier)
        {
            if (id != supplier.CompanyID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supplier);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SupplierExists(supplier.CompanyID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(supplier));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductID,Name,UnitsInStock,CategoryID,SupplierID")] Product product)
        {
            if (id != product.ProductID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.ProductID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
        public async Task <IActionResult> Edit(int id, [Bind("CategoryID,Name")] Category category)
        {
            if (id != category.CategoryID)
            {
                return(NotFound());
            }

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