public async Task <IActionResult> Edit(int id, [Bind("Id,LastName,FirstName,ContactNumber,EmailAddress,EventId")] GuestAttendee guestAttendee) { if (id != guestAttendee.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(guestAttendee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GuestAttendeeExists(guestAttendee.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } //Gets Ids and one mor property to be displayed and used in the drop down list ViewData["EventId"] = new SelectList(_context.Event, "Id", "Id", guestAttendee.EventId); return(View(guestAttendee)); }
public async Task <IActionResult> Create([Bind("Id,LastName,FirstName,ContactNumber,EmailAddress,EventId")] GuestAttendee guestAttendee) { if (ModelState.IsValid) { _context.Add(guestAttendee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //Gets Ids and one mor property to be displayed and used in the drop down list. ViewData["EventId"] = new SelectList(_context.Event, "Id", "Id", guestAttendee.EventId); return(View(guestAttendee)); }