public async Task <IActionResult> Edit(int id, [Bind("Id,Industry1,Industry2")] RelatedBranches relatedBranches) { if (id != relatedBranches.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(relatedBranches); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RelatedBranchesExists(relatedBranches.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["Industry1"] = new SelectList(_context.Branches, "Id", "Id", relatedBranches.Industry1); ViewData["Industry2"] = new SelectList(_context.Branches, "Id", "Id", relatedBranches.Industry2); return(View(relatedBranches)); }
public async Task <IActionResult> Create([Bind("Id,Industry1,Industry2")] RelatedBranches relatedBranches) { if (ModelState.IsValid) { _context.Add(relatedBranches); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["Industry1"] = new SelectList(_context.Branches, "Id", "Id", relatedBranches.Industry1); ViewData["Industry2"] = new SelectList(_context.Branches, "Id", "Id", relatedBranches.Industry2); return(View(relatedBranches)); }