public async Task <IHttpActionResult> PostMessageResepient(MessageResepient messageResepient) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.MessageResepients.Add(messageResepient); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (MessageResepientExists(messageResepient.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = messageResepient.Id }, messageResepient)); }
public async Task <IHttpActionResult> PutMessageResepient(int id, MessageResepient messageResepient) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != messageResepient.Id) { return(BadRequest()); } db.Entry(messageResepient).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MessageResepientExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetMessageResepient(int id) { MessageResepient messageResepient = await db.MessageResepients.FindAsync(id); if (messageResepient == null) { return(NotFound()); } return(Ok(messageResepient)); }
public async Task <IHttpActionResult> DeleteMessageResepient(int id) { MessageResepient messageResepient = await db.MessageResepients.FindAsync(id); if (messageResepient == null) { return(NotFound()); } db.MessageResepients.Remove(messageResepient); await db.SaveChangesAsync(); return(Ok(messageResepient)); }