public async Task <IActionResult> Edit(int id, [Bind("Id,NationalityId,MissionId,CountryOpsId,UnitOpsId")] NationalityMap nationalityMap) { if (id != nationalityMap.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(nationalityMap); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NationalityMapExists(nationalityMap.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CountryOpsId"] = new SelectList(_context.CountryOfOperation, "Id", "Name", nationalityMap.CountryOpsId); ViewData["MissionId"] = new SelectList(_context.Mission, "Id", "Name", nationalityMap.MissionId); ViewData["NationalityId"] = new SelectList(_context.Country, "Id", "Nationality", nationalityMap.NationalityId); ViewData["UnitOpsId"] = new SelectList(_context.UnitOps, "Id", "Name", nationalityMap.UnitOpsId); return(View(nationalityMap)); }
public async Task <IActionResult> Create([Bind("Id,NationalityId,MissionId,CountryOpsId,UnitOpsId")] NationalityMap nationalityMap) { if (ModelState.IsValid) { _context.Add(nationalityMap); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CountryOpsId"] = new SelectList(_context.CountryOfOperation, "Id", "Name", nationalityMap.CountryOpsId); ViewData["MissionId"] = new SelectList(_context.Mission, "Id", "Name", nationalityMap.MissionId); ViewData["NationalityId"] = new SelectList(_context.Country, "Id", "Nationality", nationalityMap.NationalityId); ViewData["UnitOpsId"] = new SelectList(_context.UnitOps, "Id", "Name", nationalityMap.UnitOpsId); return(View(nationalityMap)); }