public async Task <IActionResult> Edit(int id, [Bind("Id,StaffId,EventId")] EventStaffing eventStaffing) { if (id != eventStaffing.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(eventStaffing); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventStaffingExists(eventStaffing.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EventId"] = new SelectList(_context.Events, "Id", "Title", eventStaffing.EventId); ViewData["StaffId"] = new SelectList(_context.Staff, "Id", "Email", eventStaffing.StaffId); return(View(eventStaffing)); }
public async Task <IActionResult> Create([Bind("Id,StaffId,EventId")] EventStaffing eventStaffing) { if (ModelState.IsValid) { _context.Add(eventStaffing); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(EventIndex) + "/" + eventStaffing.EventId)); } ViewData["EventId"] = new SelectList(_context.Events, "Id", "Title", eventStaffing.EventId); ViewData["StaffId"] = new SelectList(_context.Staff, "Id", "Email", eventStaffing.StaffId); return(RedirectToAction(nameof(EventIndex) + "/" + eventStaffing.EventId)); }