public async Task <IActionResult> Edit(int id, [Bind("VolunteerId,FirstName,LastName,PhoneNumber,Relationship")] VolunteerEmergencyContact volunteerEmergencyContact) { if (id != volunteerEmergencyContact.VolunteerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(volunteerEmergencyContact); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VolunteerEmergencyContactExists(volunteerEmergencyContact.VolunteerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["VolunteerId"] = new SelectList(_context.Volunteer, "VolunteerId", "Address", volunteerEmergencyContact.VolunteerId); return(View(volunteerEmergencyContact)); }
public async Task <IActionResult> Create([Bind("VolunteerId,FirstName,LastName,PhoneNumber,Relationship")] VolunteerEmergencyContact volunteerEmergencyContact) { if (ModelState.IsValid) { _context.Add(volunteerEmergencyContact); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["VolunteerId"] = new SelectList(_context.Volunteer, "VolunteerId", "Address", volunteerEmergencyContact.VolunteerId); return(View(volunteerEmergencyContact)); }