public async Task <IActionResult> Edit(int id, [Bind("AddressInOrder1,AddressId,OrderId,Type")] AddressInOrder addressInOrder) { if (id != addressInOrder.AddressInOrder1) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(addressInOrder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressInOrderExists(addressInOrder.AddressInOrder1)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AddressId"] = new SelectList(_context.Address, "AddressId", "AddressLine1", addressInOrder.AddressId); ViewData["OrderId"] = new SelectList(_context.Order, "OrderId", "OrderGuid", addressInOrder.OrderId); return(View(addressInOrder)); }
public async Task <IActionResult> Create([Bind("AddressInOrder1,AddressId,OrderId,Type")] AddressInOrder addressInOrder) { if (ModelState.IsValid) { _context.Add(addressInOrder); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AddressId"] = new SelectList(_context.Address, "AddressId", "AddressLine1", addressInOrder.AddressId); ViewData["OrderId"] = new SelectList(_context.Order, "OrderId", "OrderGuid", addressInOrder.OrderId); return(View(addressInOrder)); }