public async Task <IActionResult> Edit(int id, [Bind("WorkAndParticipantId,WorkId,ParticipantId")] WorksAndParticipant worksAndParticipant) { if (id != worksAndParticipant.WorkAndParticipantId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(worksAndParticipant); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WorksAndParticipantExists(worksAndParticipant.WorkAndParticipantId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ParticipantId"] = new SelectList(_context.Participants, "ParticipantId", "FullName", worksAndParticipant.ParticipantId); ViewData["WorkId"] = new SelectList(_context.Works, "WorkId", "Title", worksAndParticipant.WorkId); return(View(worksAndParticipant)); }
public async Task <IActionResult> Create([Bind("WorkAndParticipantId,WorkId,ParticipantId")] WorksAndParticipant worksAndParticipant) { if (ModelState.IsValid) { _context.Add(worksAndParticipant); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ParticipantId"] = new SelectList(_context.Participants, "ParticipantId", "FullName", worksAndParticipant.ParticipantId); ViewData["WorkId"] = new SelectList(_context.Works, "WorkId", "Title", worksAndParticipant.WorkId); return(View(worksAndParticipant)); }