public async Task <IActionResult> Edit(int id, [Bind("AdministrativeUnitId,EventId,Id")] AdministrativeUnitInEvent administrativeUnitInEvent) { if (id != administrativeUnitInEvent.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(administrativeUnitInEvent); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdministrativeUnitInEventExists(administrativeUnitInEvent.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AdministrativeUnitId"] = new SelectList(_context.AdministrativeUnits, "Id", "Id", administrativeUnitInEvent.AdministrativeUnitId); ViewData["EventId"] = new SelectList(_context.Events, "Id", "Id", administrativeUnitInEvent.EventId); return(View(administrativeUnitInEvent)); }
public async Task <IActionResult> Create([Bind("AdministrativeUnitId,EventId,Id")] AdministrativeUnitInEvent administrativeUnitInEvent) { if (ModelState.IsValid) { _context.Add(administrativeUnitInEvent); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AdministrativeUnitId"] = new SelectList(_context.AdministrativeUnits, "Id", "Id", administrativeUnitInEvent.AdministrativeUnitId); ViewData["EventId"] = new SelectList(_context.Events, "Id", "Id", administrativeUnitInEvent.EventId); return(View(administrativeUnitInEvent)); }