public async Task <IActionResult> Edit(int id, EditAtendeeViewModel atendeeViewModel) { if (id != atendeeViewModel.UserID) { return(NotFound()); } if (ModelState.IsValid) { try { var atendee = _context.User .FirstOrDefault(i => i.UserID == atendeeViewModel.UserID); if (atendee != null) { atendee.ExternalID = atendeeViewModel.ExternalID; atendee.ModifiedDate = DateTime.UtcNow; } _context.Update(atendee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(atendeeViewModel.UserID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(atendeeViewModel)); }
public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var user = await _context.User.SingleOrDefaultAsync(m => m.UserID == id); if (user == null) { return(NotFound()); } var viewModel = new EditAtendeeViewModel(); viewModel.ExternalID = user.ExternalID; viewModel.UserID = user.UserID; return(View(viewModel)); }