/*Save a single record for person based on 'Add or Update' */ public bool SavePerson(Person person, String action) { if (action == "insert") { _context.Entry(person).State = EntityState.Added; } else { _context.Entry(person).State = EntityState.Modified; } return(_context.SaveChanges() >= 0); }
public async Task <ActionResult> Put(int id, [FromBody] Person value) { if (id != value.Id) { return(BadRequest()); } var person = _context.Entry(value); person.State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }