public async Task <IActionResult> Edit(int id, [Bind("Id,ActivityId,PersonId")] PeopleToActivity peopleToActivity) { if (id != peopleToActivity.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(peopleToActivity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PeopleToActivityExists(peopleToActivity.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ActivityId"] = new SelectList(_context.Activity, "Id", "ActivityName", peopleToActivity.ActivityId); ViewData["PersonId"] = new SelectList(_context.Person, "Id", "FullName", peopleToActivity.PersonId); return(View(peopleToActivity)); }
public async Task <IActionResult> Create([Bind("Id,ActivityId,PersonId")] PeopleToActivity peopleToActivity) { if (ModelState.IsValid) { _context.Add(peopleToActivity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ActivityId"] = new SelectList(_context.Activity, "Id", "ActivityName", peopleToActivity.ActivityId); ViewData["PersonId"] = new SelectList(_context.Person, "Id", "FullName", peopleToActivity.PersonId); return(View(peopleToActivity)); }