public async Task <IActionResult> Edit(int id, [Bind("ID,SupplierID,CustomerID,DeliveryDate,Price")] DeliveryToCustomer deliveryToCustomer) { if (id != deliveryToCustomer.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(deliveryToCustomer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeliveryToCustomerExists(deliveryToCustomer.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CustomerID"] = new SelectList(_context.Set <Customer>(), "ID", "ID", deliveryToCustomer.CustomerID); ViewData["SupplierID"] = new SelectList(_context.Supplier, "ID", "ID", deliveryToCustomer.SupplierID); return(View(deliveryToCustomer)); }
public async Task <IActionResult> Create([Bind("ID,DeliveryDate,Price,SupplierID,CustomerID")] DeliveryToCustomer deliveryToCustomer) { if (ModelState.IsValid) { _context.Add(deliveryToCustomer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(deliveryToCustomer)); }
public async Task <IActionResult> Create([Bind("ID,SupplierID,CustomerID,DeliveryDate,Price")] DeliveryToCustomer deliveryToCustomer) { if (ModelState.IsValid) { _context.Add(deliveryToCustomer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerID"] = new SelectList(_context.Set <Customer>(), "ID", "ID", deliveryToCustomer.CustomerID); ViewData["SupplierID"] = new SelectList(_context.Supplier, "ID", "ID", deliveryToCustomer.SupplierID); return(View(deliveryToCustomer)); }