public async Task <IActionResult> Edit(int id, [Bind("MakerId,FirstName,LastName,Gender,Age,ApplicationUserId")] PollMaker pollMaker) { if (id != pollMaker.MakerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pollMaker); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PollMakerExists(pollMaker.MakerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(pollMaker)); }
public async Task <IActionResult> Create([Bind("MakerId,FirstName,LastName,Gender,Age,ApplicationUserId")] PollMaker pollMaker, string id) { if (ModelState.IsValid) { pollMaker.ApplicationUserId = id; var currentUser = _context.Users.FirstOrDefault(u => u.Id == id); pollMaker.Email = currentUser.Email; _context.Add(pollMaker); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(pollMaker)); }