public async Task <RepositoryResultTypes> UpdateAsync(int id, ContactDetails contact) { if (id != contact.Id) { return(RepositoryResultTypes.BadRequest); } _context.Entry(contact).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactDetailsExists(id)) { return(RepositoryResultTypes.NotFound); } else { return(RepositoryResultTypes.Error); } } return(RepositoryResultTypes.NoContent); }
public async Task EditPersonAsync(Person person) { try { var local = _contactDetailsContext.Set <Person>().Local.FirstOrDefault(entry => entry.Id.Equals(entry.Id)); if (local != null) { _contactDetailsContext.Entry(local).State = EntityState.Detached; } _contactDetailsContext.Entry(person).State = EntityState.Modified; await _contactDetailsContext.SaveChangesAsync().ConfigureAwait(false); } catch (Exception ex) { Console.WriteLine(ex.Message); } }