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