public async Task <IHttpActionResult> PutTypePublication(int id, TypePublication typePublication) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != typePublication.IdTypePublication) { return(BadRequest()); } db.Entry(typePublication).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypePublicationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetTypePublication(int id) { TypePublication typePublication = await db.TypePublication.FindAsync(id); if (typePublication == null) { return(NotFound()); } return(Ok(typePublication)); }
public async Task <IHttpActionResult> PostTypePublication(TypePublication typePublication) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TypePublication.Add(typePublication); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = typePublication.IdTypePublication }, typePublication)); }
public async Task <IHttpActionResult> DeleteTypePublication(int id) { TypePublication typePublication = await db.TypePublication.FindAsync(id); if (typePublication == null) { return(NotFound()); } db.TypePublication.Remove(typePublication); await db.SaveChangesAsync(); return(Ok(typePublication)); }