public async Task <IActionResult> Edit(int id, [Bind("ProductId,Name,Price")] Products products) { if (id != products.ProductId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(products); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductsExists(products.ProductId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(products)); }
public async Task <IActionResult> Edit(int id, [Bind("CustomerId,FirstName,LastName,Email")] Customers customers) { if (id != customers.CustomerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomersExists(customers.CustomerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customers)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,OrderNum,CustomerId,ProductId,Qty")] Orders orders) { if (id != orders.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(orders); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrdersExists(orders.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Email", orders.CustomerId); ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", orders.ProductId); return(View(orders)); }