public async Task <IActionResult> Edit(int id, [Bind("PairId,ProductQuantity,ProductId,OrderId")] ProductOrderPair productOrderPair) { if (id != productOrderPair.PairId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(productOrderPair); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductOrderPairExists(productOrderPair.PairId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["OrderId"] = new SelectList(_context.Orders, "OrderId", "OrderId", productOrderPair.OrderId); ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName", productOrderPair.ProductId); return(View(productOrderPair)); }
public async Task <IActionResult> Create([Bind("PairId,ProductQuantity,ProductId,OrderId")] ProductOrderPair productOrderPair) { if (ModelState.IsValid) { _context.Add(productOrderPair); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["OrderId"] = new SelectList(_context.Orders, "OrderId", "OrderId", productOrderPair.OrderId); ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName", productOrderPair.ProductId); return(View(productOrderPair)); }