public async Task <IActionResult> Edit(int id, [Bind("UserForOrderId,AspnetuserId,OrderId,Type")] UserForOrder userForOrder) { if (id != userForOrder.UserForOrderId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userForOrder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserForOrderExists(userForOrder.UserForOrderId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AspnetuserId"] = new SelectList(_context.AspNetUsers, "Id", "Id", userForOrder.AspnetuserId); ViewData["OrderId"] = new SelectList(_context.Order, "OrderId", "OrderGuid", userForOrder.OrderId); return(View(userForOrder)); }
public async Task <IActionResult> Create([Bind("UserForOrderId,AspnetuserId,OrderId,Type")] UserForOrder userForOrder) { if (ModelState.IsValid) { _context.Add(userForOrder); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AspnetuserId"] = new SelectList(_context.AspNetUsers, "Id", "Id", userForOrder.AspnetuserId); ViewData["OrderId"] = new SelectList(_context.Order, "OrderId", "OrderGuid", userForOrder.OrderId); return(View(userForOrder)); }