public async Task <IActionResult> Edit(int id, [Bind("HomeCookId,FirstName,LastName,IdentityUserId")] HomeCook homeCook) { if (id != homeCook.HomeCookId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(homeCook); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HomeCookExists(homeCook.HomeCookId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdentityUserId"] = new SelectList(_context.Users, "Id", "Id", homeCook.IdentityUserId); return(View(homeCook)); }
public async Task <IActionResult> Create([Bind("HomeCookId,FirstName,LastName,IdentityUserId")] HomeCook homeCook) { if (ModelState.IsValid) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); homeCook.IdentityUserId = userId; _context.Add(homeCook); _context.Add(homeCook); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdentityUserId"] = new SelectList(_context.Users, "Id", "Id", homeCook.IdentityUserId); return(View(homeCook)); }