public async Task <IActionResult> PutPerson(int id, Person person) { if (id != person.Id) { return(BadRequest()); } _context.Entry(person).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,BirthDate,DeathDate,IsMale,Father,Mother,DataOwnerId")] Person person) { if (ModelState.IsValid) { _context.Add(person); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } SavePotentialParentsAndSexesInViewData(person); return(View(person)); }
public async Task <IActionResult> Create([Bind("Id,Firstname,Lastname,Birthdate,Deathdate,Father,Mother,Ismale")] Person person) { if (ModelState.IsValid) { _context.Add(person); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Father"] = new SelectList(_context.Person, "Id", "Id", person.Father); ViewData["Mother"] = new SelectList(_context.Person, "Id", "Id", person.Mother); return(View(person)); }