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