public async Task <IHttpActionResult> PutContact(int id, Contact contact) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != contact.Id) { return(BadRequest()); } db.Entry(contact).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Save Changes Async /// </summary> /// <returns></returns> public Task <int> Save() { return(_context.SaveChangesAsync()); }
public async Task AddContact(Contact contact) { _context.Contacts.Add(contact); await _context.SaveChangesAsync(); }