public async Task <IActionResult> OrderDetailEdit(string id, OrderDetail editorderDetail) { var result = ProductAndOrder.FindIds(id); // Custom Function to get from the param href the orderid and product id editorderDetail.ProductId = result.productid; editorderDetail.OrderId = result.orderid; ModelState.Clear(); if (ModelState.IsValid) { try { _context.Update(editorderDetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderDetailExists(editorderDetail.OrderId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(editorderDetail)); }
// Edit order Detail Item public async Task <IActionResult> OrderDetailEdit(string id) { var result = ProductAndOrder.FindIds(id); // Custom Function to get from the param href the orderid and product id var detail = await _context.OrderDetails.FindAsync(result.orderid, result.productid); if (detail != null) { ViewData["OrderId"] = detail.OrderId; } ViewData["ProductId"] = new SelectList(_context.Products, "ProductId", "ProductName"); return(View(detail)); }