public async Task <IActionResult> Create(Person person) { _context.Persons.Add(person); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetById), new { id = person.FirstName }, person)); }
public async Task <IActionResult> PutPerson(string id, Person person) { if (id != person.FirstName) { return(BadRequest()); } _context.Entry(person).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }