public async Task <IActionResult> Edit(long id, [Bind("Id,IssueTime,CustomerId,RestaurantId,IssueDate,PlannedTime,PlannedDate")] MyapiOrder myapiOrder) { if (id != myapiOrder.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(myapiOrder); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MyapiOrderExists(myapiOrder.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.MyapiCustomers, "Id", "Email", myapiOrder.CustomerId); ViewData["RestaurantId"] = new SelectList(_context.MyapiRestaurants, "Id", "Address", myapiOrder.RestaurantId); return(View(myapiOrder)); }
public async Task <IActionResult> Create([Bind("Id,IssueTime,CustomerId,RestaurantId,IssueDate,PlannedTime,PlannedDate")] MyapiOrder myapiOrder) { if (ModelState.IsValid) { _context.Add(myapiOrder); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.MyapiCustomers, "Id", "Email", myapiOrder.CustomerId); ViewData["RestaurantId"] = new SelectList(_context.MyapiRestaurants, "Id", "Address", myapiOrder.RestaurantId); return(View(myapiOrder)); }