public IHttpActionResult PuttAccountContact(int id, tAccountContact tAccountContact) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tAccountContact.ID) { return(BadRequest()); } db.Entry(tAccountContact).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tAccountContactExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetAccountContact(int id) { tAccountContact accountContact = db.tAccountContacts.Find(id); if (accountContact == null) { return(NotFound()); } return(Ok(accountContact)); }
public IHttpActionResult PosttAccountContact(tAccountContact tAccountContact) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tAccountContacts.Add(tAccountContact); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tAccountContact.ID }, tAccountContact)); }
public IHttpActionResult DeletetAccountContact(int id) { tAccountContact tAccountContact = db.tAccountContacts.Find(id); if (tAccountContact == null) { return(NotFound()); } db.tAccountContacts.Remove(tAccountContact); db.SaveChanges(); return(Ok(tAccountContact)); }