public async Task <IActionResult> Edit(int id, [Bind("SuppliedByID,SupplierID,Project_Code")] SuppliedBy suppliedBy) { if (id != suppliedBy.SuppliedByID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(suppliedBy); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SuppliedByExists(suppliedBy.SuppliedByID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Project_Code"] = new SelectList(_context.Projects, "Project_Code", "Project_Code", suppliedBy.Project_Code); ViewData["SupplierID"] = new SelectList(_context.Suppliers, "SupplierID", "Supplier_name", suppliedBy.SupplierID); return(View(suppliedBy)); }
public async Task <IActionResult> Create([Bind("SuppliedByID,SupplierID,Project_Code")] SuppliedBy suppliedBy) { if (ModelState.IsValid) { _context.Add(suppliedBy); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Project_Code"] = new SelectList(_context.Projects, "Project_Code", "Project_Code", suppliedBy.Project_Code); ViewData["SupplierID"] = new SelectList(_context.Suppliers, "SupplierID", "Supplier_name", suppliedBy.SupplierID); return(View(suppliedBy)); }